3个回答
展开全部
ArrayList GetAll(DirectoryInfo dir)//搜索文件夹中的文件
{
ArrayList FileList = new ArrayList();
FileInfo[] allFile = dir.GetFiles();
foreach (FileInfo fi in allFile)
{
FileList.Add(fi.Name);
}
DirectoryInfo[] allDir= dir.GetDirectories();
foreach (DirectoryInfo d in allDir)
{
GetAll(d);
}
return FileList;
}
DirectoryInfo d = new DirectoryInfo(@"F:\");
ArrayList Flst= GetAll(d);
{
ArrayList FileList = new ArrayList();
FileInfo[] allFile = dir.GetFiles();
foreach (FileInfo fi in allFile)
{
FileList.Add(fi.Name);
}
DirectoryInfo[] allDir= dir.GetDirectories();
foreach (DirectoryInfo d in allDir)
{
GetAll(d);
}
return FileList;
}
DirectoryInfo d = new DirectoryInfo(@"F:\");
ArrayList Flst= GetAll(d);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询