展开全部
static void ShowFiles(string path)
{
DirectoryInfo floder = Directory.CreateDirectory(path);
DirectoryInfo[] subFloders = floder.GetDirectories();
FileInfo[] files = floder.GetFiles();
Console.WriteLine(path+" 目录数:{0} 文件数:{1}",subFloders.Length,files.Length);
foreach (DirectoryInfo dir in subFloders)
{
Console.WriteLine(" 子目录:" + dir.FullName);
}
foreach (FileInfo file in files)
{
Console.WriteLine(file.FullName);
}
foreach (DirectoryInfo dir in subFloders)
{
Console.WriteLine("\r\n\r\n");
//递归调用
ShowFiles(dir.FullName);
}
}
{
DirectoryInfo floder = Directory.CreateDirectory(path);
DirectoryInfo[] subFloders = floder.GetDirectories();
FileInfo[] files = floder.GetFiles();
Console.WriteLine(path+" 目录数:{0} 文件数:{1}",subFloders.Length,files.Length);
foreach (DirectoryInfo dir in subFloders)
{
Console.WriteLine(" 子目录:" + dir.FullName);
}
foreach (FileInfo file in files)
{
Console.WriteLine(file.FullName);
}
foreach (DirectoryInfo dir in subFloders)
{
Console.WriteLine("\r\n\r\n");
//递归调用
ShowFiles(dir.FullName);
}
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询