/// <summary>
/// 递归文件夹获得总大小
/// </summary>
/// <param name="dir"></param>
/// <returns></returns>
public long countsize(System.IO.DirectoryInfo dir)
{
long size = 0;
FileInfo[] files = dir.GetFiles();
foreach (System.IO.FileInfo info in files)
{
size += info.Length;
}
DirectoryInfo[] dirs = dir.GetDirectories();
foreach (DirectoryInfo dirinfo in dirs)
{
size += countsize(dirinfo);
}
return size;
}
C#递归文件夹获得总大小
最新推荐文章于 2024-08-19 20:52:19 发布