Results 1 to 3 of 3

Thread: Select parts of a file...

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2002
    Posts
    12

    Select parts of a file...

    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.
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    Nov 2002
    Location
    Växjö, Sweden
    Posts
    314
    You can use a BinaryReader to read characters from the file.


    Code:
    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

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2002
    Posts
    12
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width