【问题标题】:How to get the length of written bytes with BinaryWriter?如何使用 BinaryWriter 获取写入字节的长度?
【发布时间】:2017-07-06 19:37:34
【问题描述】:

考虑一个简单的 BinaryWriter 过程:

using (BinaryWriter writer = new BinaryWriter(File.Open(fileName, FileMode.Create)))
        {
            writer.Write(10000);
            writer.Write("Temp");
            writer.Write(30);
            writer.Write(50.6);
        }

现在,我怎样才能得到 BinaryWriter 写入的字节总数?以及如何将此数量附加到当前的 writer 对象,例如writer.Write(totalNumberAsBytes)

【问题讨论】:

    标签: c# binarywriter


    【解决方案1】:

    你试过writer.BaseStream.Length吗?这应该是流中的字节数。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-09
      • 2020-11-25
      • 1970-01-01
      • 2013-10-30
      • 1970-01-01
      • 2017-08-05
      相关资源
      最近更新 更多