Binary files

K

kate2006

hi guys,
I am having problem reading binary file ? I dont know what is written
inside the binary file ( prob numbers) , but i tried so many times with
different parameters but not able to get the output... any idea??
 
J

Jon Skeet [C# MVP]

kate2006 said:
I am having problem reading binary file ? I dont know what is written
inside the binary file ( prob numbers) , but i tried so many times with
different parameters but not able to get the output... any idea??

Without seeing any of your code, or knowing what problem you're
actually encountering, we can't possibly tell.

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.
 
C

Cor Ligthert [MVP]

Hi Bernie,

Good to see you back. However in the way you are answering was once the
reason that I changed my Nick to Corrina when I had a problem.

:)

Cor
 
K

kate2006

I am trying to read a file written in binary format !!! through this
code i can execute hex coding of file and convert it in binary ..but i
found out that the file contain signed character(128), how can i come
up with signed value...

thanx

Dim fs As FileStream = New FileStream(txtbrowse.Text, FileMode.Open)
Dim w As BinaryWriter = New BinaryWriter(fs)
Dim r As BinaryReader = New BinaryReader(fs)

Dim MySize As Long
MySize = FileLen(txtbrowse.Text)
Dim p as integer
Dim ar() As Integer
Dim s As Integer
Dim s1 As String

For p = 0 To MySize
s = r.ReadByte
s1 = Convert.ToInt32(s)
ListBox1.Items.Add(s1)
Next
fs.Close()
 
J

Jon Skeet [C# MVP]

kate2006 said:
I am trying to read a file written in binary format !!!

*What* binary format though? Saying that the file is written in "binary
format" is like saying that a book is written in "a language".
through this
code i can execute hex coding of file and convert it in binary ..but i
found out that the file contain signed character(128), how can i come
up with signed value...

Firstly, don't confuse characters with bytes. If this is a binary file,
characters shouldn't come into it.

It would really help if you'd give us a short but *complete* example
program that demonstrates the problem, along with a sample of the data
and what you'd expect to get back.

As I said before, read http://www.pobox.com/~skeet/csharp/complete.html

Your current code is reading a byte at a time, but we've no idea what
you *want* to be reading, or how that data is formatted.
 
G

Guest

do you know what to expect when reading the file? if not you are in for a lot
of detective work work usng a binary editor trying to work out what is there
- and that is mainly down to experience. If this is the case dump some of the
file and i will have a look at the w/e

(e-mail address removed)
--guy--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top