- using System.IO;
-
-
-
-
-
- public string GetAllFolder(string path)
- {
- string folder_Names = "";
- DirectoryInfo dir = new DirectoryInfo(path);
-
- foreach (DirectoryInfo subdir in dir.GetDirectories())
- folder_Names += subdir.FullName + ",";
-
- return folder_Names;
- }
using System.IO;
/// <summary>
/// 獲取指定目錄下的所有文件夾名
/// </summary>
/// <param name="path">目錄路徑</param>
/// <returns>string,返回所有文件夾名字</returns>
public string GetAllFolder(string path)
{
string folder_Names = "";
DirectoryInfo dir = new DirectoryInfo(path);
foreach (DirectoryInfo subdir in dir.GetDirectories())
folder_Names += subdir.FullName + ",";
return folder_Names;
}
- using System.IO;
-
-
-
-
-
- protected long GetDirectorySize(string path)
- {
- long dirSize = 0;
- DirectoryInfo dir = new DirectoryInfo(path);
- foreach (FileInfo file in dir.GetFiles())
- dirSize += file.Length;
- foreach (DirectoryInfo subdir in dir.GetDirectories())
- dirSize += GetDirectorySize(subdir.FullName);
- return dirSize;
- }