Reading Binary File


I have a binary file that contains some information i need to extract

Within this file if you open it up in wordpad there is a line with CLIENT on it

after the client are several characters in binary that need to be extracted. (TtäUt)

I have opened the file in ascii mode (using streamReader) and found client word and the exact data i need, but when it comes back part of the information is missing.

it only shows TtUt and the ä is missing.

Does anyone know what is happening?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Try specifiying the encoding, for example:
  Dim reader1 As New StreamReader("c:\somefile.dat", Encoding.Default)
  Dim text1 As String = reader1.ReadToEnd

...or use a BinaryReader instead
    Dim st As New IO.FileStream("c:\somefile.dat", IO.FileMode.Open)
    Dim br As New IO.BinaryReader(st)
    Dim data() As Byte = br.ReadBytes(CInt(st.Length))

/ Jon

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
wordpad is designed to view text files rather than binary.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.