Read Binary File

SIMIN

Well-known member
Joined
Mar 10, 2008
Messages
92
Hi eveyone.
I would like to read a binary file: Windows Address Book.
However, since I JUST want to import email addresses from WAB to my application I think I can open and read it myself.
If you see my snapshot, email addresses are human readable and just with spaces, not encoded!
So I think this command will open file file well:
Code:
Dim ReadText As Byte() = System.IO.File.ReadAllBytes("C:\Documents and Settings\Username\Application Data\Microsoft\Address Book\Username.wab")
The only problem is that I never tried to read binary files.
And dont know how to process this Byte variable: ReadText!
Do you have any idea how can I just extract email addresses?
I even have regex code to do it, but dont know how to process ReadText?
Please help me :(
 
Last edited by a moderator:
You would really need to know the underlying file structure to be sure you could get the information correctly. Not sure how a RegEx would handle the non text data in the file either.
 
I believe that what you are looking for is this:

Code:
Dim str as String = System.Text.Encoding.ASCII.GetString(ReadText)

However, as PD states, youll need to know the file structure to ensure that your application does not get tricked by "non-standard" data in the file.
 
Yeh, thats a slippery slope. I would definitely not try to parse a binary file with regexs. If a field changes the regex may not work. Also, your assumption is that the current file format is the full specification, which it may not be. There may be fields missing because it is the 1st of the month or some weird rule like that.

Is there a MS spec or api to read this file?
 

Similar threads

Back
Top