Reputation: 69
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)
Upvotes: 4
Views: 1401
Reputation: 4037
Have you tried writer.BaseStream.Length
? This should be the amount of bytes in the stream.
Upvotes: 5