Using the BinaryWriter???

G

Guest

I am using the BinaryWriter to write binary information to the end of a file. When i write the info the string always starts with â–¡, so my string turns out to be "â–¡MyString", what am i missing here

--- Here is the code that i am using to make this happen, like i said, it works but when i use the binaryReader to read the file i get â–¡ in front of the string

Dim binWriter As New BinaryWriter(sfile
binWriter.BaseStream.Seek(-129, SeekOrigin.End

binWriter.Write("MyString"

binWriter.Flush(
binWriter.Close(
sfile.Close(

Thanks Eric
 
M

Mattias Sjögren

When i write the info the string always starts with ?, so my string turns out to be "?MyString", what am i missing here?

BinaryWriter writes a length-prefixed string to the stream. The ? is
probably the result of interpreting the length integer as a character.

If you don't want the length written, use a StreamWriter instead, or
BinaryWriter.Write(char[]).



Mattias
 

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