Considering a simple BinaryWriter procedure:
using (BinaryWriter writer = new BinaryWriter(File.Open(fileName, FileMode.Create)))
{
writer.Write(10000);
writer.Write("Temp");
writer.Write(30);
writer.Write(50.6);
}
How can I get the total number of bytes written by the BinaryWriter? And how can I append this amount to the current writer object, e.g. writer.Write(totalNumberAsBytes)
Have you tried writer.BaseStream.Length? This should be the amount of bytes in the stream.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With