Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何查找文件中的字节数?_C#_File_Size_Byte - Fatal编程技术网

C# 如何查找文件中的字节数?

C# 如何查找文件中的字节数?,c#,file,size,byte,C#,File,Size,Byte,我在申请C#。在这里,我想找出特定文件中的字节数。这里我使用代码作为 using(FileStream fs=new FileStream(filename,FileMode.Open,FileAccess.Read)) { //Here i want to find the number of Bytes. //Some more code. } 请帮助我。提前谢谢。您可以使用该类获取其字节数(作为Int64): 使用属性 获取流的长度(以字节为单位) new FileInf

我在申请C#。在这里,我想找出特定文件中的字节数。这里我使用代码作为

using(FileStream fs=new FileStream(filename,FileMode.Open,FileAccess.Read))
{
    //Here i want to find the number of Bytes.
    //Some more code.
}
请帮助我。提前谢谢。

您可以使用该类获取其字节数(作为
Int64
):

使用属性

获取流的长度(以字节为单位)

new FileInfo(filename).Length;