簡體   English   中英

如何查找文件中的字節數?

[英]how to find the number of bytes in a file?

我在C#中申請。 在這里,我想找出特定文件中的字節數。 我在這里使用代碼

using(FileStream fs=new FileStream(filename,FileMode.Open,FileAccess.Read))
{
    //Here i want to find the number of Bytes.
    //Some more code.
}

請幫幫我。謝謝。

您可以使用FileInfo類以字節為單位獲取其長度 (作為Int64 ):

new FileInfo(filename).Length;

使用FileStream.Length屬性。

獲取流的長度(以字節為單位)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM