SIMIN Posted January 4, 2009 Posted January 4, 2009 (edited) 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: 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 don't 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 don't know how to process ReadText? Please help me :( Edited January 4, 2009 by SIMIN Quote
Administrators PlausiblyDamp Posted January 5, 2009 Administrators Posted January 5, 2009 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. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Nate Bross Posted January 5, 2009 Posted January 5, 2009 I believe that what you are looking for is this: Dim str as String = System.Text.Encoding.ASCII.GetString(ReadText) However, as PD states, you'll need to know the file structure to ensure that your application does not get tricked by "non-standard" data in the file. Quote ~Nate� ___________________________________________ Please use the [vb]/[cs] tags on posted code. Please post solutions you find somewhere else. Follow me on Twitter here.
Diesel Posted January 5, 2009 Posted January 5, 2009 Yeh, that's a slippery slope. I would definitely not try to parse a binary file with regex's. 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? Quote
Nate Bross Posted January 5, 2009 Posted January 5, 2009 Try: http://msdn.microsoft.com/en-us/library/ms629361(VS.85).aspx Quote ~Nate� ___________________________________________ Please use the [vb]/[cs] tags on posted code. Please post solutions you find somewhere else. Follow me on Twitter here.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.