当前位置:首页 > 开发 > C# > 正文内容

C# 获取目录大小

C#4年前 (2022-10-30)
public static long GetDirSize(string dir)
{
    long size = 0;
    string[] files = Directory.GetFiles(dir);
    foreach (string item in files)
    {
size += new FileInfo(item).Length;
    }
    string[] dirs = Directory.GetDirectories(dir);
    foreach (string item in dirs)
    {
size += GetDirSize(item);
    }
    return size;
}


转载请注明出处。

本文链接:http://pythonopen.com/?id=236

相关文章

C# 数据类型

Type ByteLenghtMinMax.NET Framework Typedefau...

C# 获取带有焦点的控件

this.ActiveControl...

C# 请确保您的 Main 函数带有 STAThreadAttribute 标记。”

System.Threading.ThreadStateException:“在可以调用 OLE 之...

C# 将函数作为参数传递

无参数    static void Main(s...

C# 可空参数

using System; using System.Runtime.Inte...

C# double转为string并保留两位小数

在 C# 中,可以使用多种方式将 double 类型的数据转换为 string 类型并保留两位小数,...