FileStream.Seek Method Sets the current position of this stream to the given value.
Imports System
Imports System.IO
Public Class FSSeek
Public Shared Sub Main()
Dim fs As New FileStream("c:\temp\temp.txt", FileMode.Open, FileAccess.Read)
Dim offset As Long
For offset = fs.Length - 1 To 0 Step -1
fs.Seek(offset, SeekOrigin.Begin)
Console.Write(Convert.ToChar(fs.ReadByte()))
Next
For offset = 1 To fs.Length
fs.Seek(-offset, SeekOrigin.End)
Console.Write(Convert.ToChar(fs.ReadByte()))
Next offset
fs.Seek(0, SeekOrigin.End)
For offset = 0 To fs.Length - 1
fs.Seek(-1, SeekOrigin.Current)
Console.Write(Convert.ToChar(fs.ReadByte()))
fs.Seek(-1, SeekOrigin.Current)
Next offset
Console.WriteLine()
fs.Close()
End Sub
End Class
Related examples in the same category