using System.IO;
///
/// 获取指定目录下的所有文件夹名
///
/// 目录路径
/// string,返回所有文件夹名字
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;
}
///
/// 获取指定目录下的所有文件和文件夹大小
///
/// 目录路径
/// string,返回所有文件夹名字
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;
}
///
/// 获取指定目录下的所有文件夹名
///
/// 目录路径
/// string,返回所有文件夹名字
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;
}
///
/// 获取指定目录下的所有文件和文件夹大小
///
/// 目录路径
/// string,返回所有文件夹名字
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;
}