Why is BinaryWriter() is inserting unwanted bytes?
-
Hi, I'm using Visual Studio 2005 C++/CLI. I have a requirement that needs to write some ASCII to a file followed by binary data. I set up a BinaryWriter(FileStream) and everything is okay except that there is a byte preceding the String^ variables denoting the number of characters to follow. I do not want these "extra" bytes in the file. Is there a way to surpress these bytes from being written to the file? Thanks, Buck
-
Hi, I'm using Visual Studio 2005 C++/CLI. I have a requirement that needs to write some ASCII to a file followed by binary data. I set up a BinaryWriter(FileStream) and everything is okay except that there is a byte preceding the String^ variables denoting the number of characters to follow. I do not want these "extra" bytes in the file. Is there a way to surpress these bytes from being written to the file? Thanks, Buck
You need to write the String chars yourself. BinaryWriter has a Write() method that writes a Char.
for (int i = 0; i < str->Length; i++)
writer->Write(str[i]);Of course, you won't be able to read the data back in as a String without some way of indicating where strings end in the file. Mark
Mark Salsbery Microsoft MVP - Visual C++ :java: