static void Main(string[] args)
{
string topPath = @"F:\";
StreamWriter sw = null;
try
{
//创建输出流,将得到文件名子目录名保存到txt中
sw = new StreamWriter(new FileStream("fileList.txt", FileMode.Append));
sw.WriteLine("根目录:" + topPath);
getDirectory(sw, topPath, 2);
}
catch (IOException e)
{
Console.WriteLine(e.Message);
}
finally
{
if (sw != null)
{
sw.Close();
Console.WriteLine("完成");
}
}
}
/// <summary>
/// 获得指定路径下所有文件名
/// </summary>
/// <param name="sw">文件写入流</param>
/// <param name="path"
C# 获取路径下所有文件夹名,文件名
最新推荐文章于 2021-06-03 15:21:29 发布