你如何在C#中的文件的大小? [英] How do you get the file size in C#?

查看:103
本文介绍了你如何在C#中的文件的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一种方式来获得使用C#的文件的大小,而不是在磁盘上的大小。这怎么可能?

I need a way to get the size of a file using C#, and not the size on disk. How is this possible?

目前我有这样的循环

foreach (FileInfo file in downloadedMessageInfo.GetFiles())
{
    //file.Length (will this work)
}

这是否会返回大小或磁盘上的大小?

Will this return the size or the size on disk?

推荐答案

FileInfo.Length 将返回文件的长度,以字节为单位(在磁盘上没有大小),所以这是你在​​找什么,我想。

FileInfo.Length will return the length of file, in bytes (not size on disk), so this is what you are looking for, I think.

这篇关于你如何在C#中的文件的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆