Sets the current position of this stream to the given value.
using System;
using System.IO;
public class FSSeek
{
public static void Main()
{
FileStream fs = new FileStream(@"c:\temp.txt", FileMode.Open, FileAccess.Read);
long offset;
for (offset = fs.Length - 1; offset >= 0; offset--)
{
fs.Seek(offset, SeekOrigin.Begin);
Console.Write(Convert.ToChar(fs.ReadByte()));
}
fs.Seek(0, SeekOrigin.End);
for (offset = 0; offset < fs.Length; offset++)
{
fs.Seek(-1, SeekOrigin.Current);
Console.Write(Convert.ToChar(fs.ReadByte()));
fs.Seek(-1, SeekOrigin.Current);
}
fs.Close();
}
}
Related examples in the same category