2

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);
        }

Now, how can I get the total number of written bytes by the BinaryWriter? And how to append this amount to the current writer object, e.g. writer.Write(totalNumberAsBytes)

Pythonic
  • 49
  • 5

1 Answers1

3

Have you tried writer.BaseStream.Length? This should be the amount of bytes in the stream.

Max Play
  • 3,717
  • 1
  • 22
  • 39