![](/img/trans.png)
[英]how can i modify a small section of bytes in a memory stream, that was written to using binarywriter
[英]How to get the length of written bytes with BinaryWriter?
考慮一個簡單的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)
您是否嘗試過writer.BaseStream.Length
? 這應該是流中的字節數。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.