943,983 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 5498
  • VB.NET RSS
Sep 16th, 2007
0

Reading the first four bytes of a (binary) files?

Expand Post »
Hi there, I was wondering if there was an easy way to read the first four bytes of a file. The ones in particular I'm looking for are 49 42 53 50 ("IBSP") and 46 42 53 50 ("FBSP"), but that bit should be easy.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
AzraelUK is offline Offline
3 posts
since Sep 2007
Sep 16th, 2007
0

Re: Reading the first four bytes of a (binary) files?

When you say bytes do you really mean the first four bytes or do you mean the first four numbes? I have a suspicion you mean the latter.
Last edited by iamthwee; Sep 16th, 2007 at 4:52 pm.
Featured Poster
Reputation Points: 1536
Solved Threads: 431
Posting Expert
iamthwee is offline Offline
5,865 posts
since Aug 2005
Sep 18th, 2007
0

Re: Reading the first four bytes of a (binary) files?

Uhh... the first four hexadecimal numbers if you open the file in a hex editor. As I evidently didn't imply, when you open it in Notepad, the first four characters are either IBSP or FBSP.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
AzraelUK is offline Offline
3 posts
since Sep 2007
Sep 18th, 2007
0

Re: Reading the first four bytes of a (binary) files?

Try this:
VB.NET Syntax (Toggle Plain Text)
  1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  2. TextBox1.Text = String.Empty
  3. Using fs As New FileStream("c:\test.txt", FileMode.Open)
  4. fs.Position = 0
  5. Using br As New BinaryReader(fs)
  6. For x As Int16 = 0 To 3
  7. TextBox1.Text &= Asc(br.ReadChar) & " "
  8. Next
  9. End Using
  10. End Using
  11. End Sub
Reputation Points: 84
Solved Threads: 58
Posting Pro in Training
waynespangler is offline Offline
461 posts
since Dec 2002
Sep 18th, 2007
0

Re: Reading the first four bytes of a (binary) files?

Hmm... Type 'FileStream' is not defined :/
Reputation Points: 10
Solved Threads: 0
Newbie Poster
AzraelUK is offline Offline
3 posts
since Sep 2007
Sep 18th, 2007
0

Re: Reading the first four bytes of a (binary) files?

import System.IO
Reputation Points: 84
Solved Threads: 58
Posting Pro in Training
waynespangler is offline Offline
461 posts
since Dec 2002
Nov 3rd, 2010
0
Re: Reading the first four bytes of a (binary) files?
hi i'm yasser from iraq i'm in the last year in computer science and i have project abaut the encryption on the mpeg file by using vb6 and i realy do not known any think about reading firt 4 byte from mpeg file i need your help and i must read this file by using open function
Reputation Points: 10
Solved Threads: 0
Newbie Poster
yasserjasem is offline Offline
1 posts
since Nov 2010

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: Date conversion
Next Thread in VB.NET Forum Timeline: Image Viewer Problem.





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC