public long GetDirectoryLength(string dirPath){
    if(!Directory.Exists(dirPath))return 0;

    long len=0;
    DirectoryInfo di=new DirectoryInfo(dirPath);
    foreach(FileInfo fi in di.GetFiles()){
        len+=fi.Length;
    }
    
    DirectoryInfo[] dis=di.GetDirectories();
    if(dis.Length>0){
        for(int i=0;i<dis.Length;i++){
            len+=GetDirectoryLength(dis[i].FullName);
        }
    }
    return len;
}

相关文章:

  • 2022-12-23
  • 2021-12-03
  • 2021-08-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-12
  • 2022-02-26
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-07
  • 2021-08-15
  • 2022-01-01
  • 2021-05-25
相关资源
相似解决方案