比如说 有个 MM.TXT 文件想知道它的大小 怎么 实现??
谢谢大家帮忙~~
谢谢大家帮忙~~
解决方案 »
- C#获取excel表名是乱码(中文部分变成问号)。
- 利用程序自动 打开文件
- 散分....
- 有关VS05的注释,请帮忙看看
- 已经生成了包含html标记的内容。如何生成html静态文件!并将路径放入“字段”中!!急啊!在线等
- 求一套简单的,设计比较规范的用c3写的web程序,必定重谢!!!!!!!!!
- 三层的困惑!
- VS2010在XP下报错的问题:System.Windows.Build2006.TypeCoverMarkup.extension
- <%# DataBinder.Eval(Container.DataItem, "Price", "{0:c}") %>这里的{0:c}是什么意思?还有什么样的形式?
- 大家好(新年好):请问在C#中如何得到呢?内宾如下:去在线呀
- C# access bool
- 求数据库映射成类文件的代码生成器的原理
DirectoryInfo directoryInfo=new DirectoryInfo(path);
long length=0;
foreach( FileSystemInfo fsi in directoryInfo.GetFileSystemInfos() ) {
if ( fsi is FileInfo ) {
length += ((FileInfo)fsi).Length;
}
else {
length +=GetFilesSize(fsi.FullName);
}
}
return length;
}
这是一个获得 文件夹 大小的 SAMPLE 怎么样能 获得 文件的大小呢???
MessageBox.Show(f.Length.ToString());
// of the files in the specified directory.
using System;
using System.IO;public class FileLength
{
public static void Main()
{
// Make a reference to a directory.
DirectoryInfo di = new DirectoryInfo("c:\\");
// Get a reference to each file in that directory.
FileInfo[] fiArr = di.GetFiles();
// Display the names and sizes of the files.
Console.WriteLine("The directory {0} contains the following files:", di.Name);
foreach (FileInfo f in fiArr)
Console.WriteLine("The size of {0} is {1} bytes.", f.Name, f.Length);
}
}
//This code produces output similar to the following;
//results may vary based on the computer/file structure/etc.:
//
//The directory c:\ contains the following files:
//The size of MyComputer.log is 274 bytes.
//The size of AUTOEXEC.BAT is 0 bytes.
//The size of boot.ini is 211 bytes.
//The size of CONFIG.SYS is 0 bytes.
//The size of hiberfil.sys is 1072775168 bytes.
//The size of IO.SYS is 0 bytes.
//The size of MASK.txt is 2700 bytes.
//The size of mfc80.dll is 1093632 bytes.
//The size of mfc80u.dll is 1079808 bytes.
//The size of MSDOS.SYS is 0 bytes.
//The size of NTDETECT.COM is 47564 bytes.
//The size of ntldr is 250032 bytes.
//The size of pagefile.sys is 1610612736 bytes.
//The size of UpdatePatch.log is 22778 bytes.
//The size of UpdatePatch.txt is 30 bytes.
//The size of wt3d.ini is 234 bytes.
{
//取得文件大小
FileInfo MyFileInfo = new FileInfo(FileName);
float MyFileSize = (float)MyFileInfo.Length / (1024 * 1024);
}
/1024 KB
/1024 M