.Net System.IO 获取文件夹下所有子文件夹名及目录
//获取path下所有的文件夹
System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(path);
System.IO.DirectoryInfo[] folders = dir.GetDirectories();
//获取文件夹名
string[] folderName = new string[folders.Length];
string[] folderPath = new string[folders.Length];
int leng = 0;
foreach (System.IO.DirectoryInfo item in folders)
{
//获取文件夹名
folderName[leng] = item.Name;
//获取子目录路径
folderPath[leng] = path + @"\" + item.Name;
leng++;
}
本文介绍如何使用.Net System.IO命名空间下的DirectoryInfo类来获取指定路径下的所有子文件夹名称及其完整路径。通过实例展示了如何遍历并获取每个子文件夹的信息。
1083

被折叠的 条评论
为什么被折叠?



