Click to See Complete Forum and Search --> : Select parts of a file...
airedale
Nov 27th, 2002, 08:48 PM
I am trying to open a dat file and move to certain positions in it (like char #4 and take the next 4 characters from it). What command is there to move through a file like that? This is the file I am trying to move through in case anyone wants to see it.
Athley
Nov 28th, 2002, 01:34 AM
You can use a BinaryReader to read characters from the file.
Dim s As Stream = File.OpenRead("c:\Test.txt")
Dim br As New BinaryReader(s)
Dim c As Integer
Dim sb As New System.Text.StringBuilder()
s.Seek(4, SeekOrigin.Begin)
For c = 1 To 4
sb.Append(Strings.Chr(br.ReadByte))
Next
TextBox1.Text = sb.ToString
airedale
Nov 29th, 2002, 04:14 PM
so this looks pretty straight forward. I am going to have to play around with it to see if I understand it all... thanks for the input.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.