C# 把文件夹下所有文件添加到集合中

private List<string> FindFile(string Path)
{
List<string> list=new List<string>();
DirectoryInfo di = new DirectoryInfo(@"C:\Users\Administrator\Desktop\File\");
FileInfo[] fis = di.GetFiles();
for (int i = 0; i < fis.Length; i++)
{
list.Add(fis[i].FullName);
}
return list;
}

 

//调用

List<string> pathList = new List<string>(); 
pathList = FindFile(@"C:\Users\Administrator\Desktop\File\");

posted @ 2017-11-07 10:19  _小马哥  阅读(1205)  评论(0编辑  收藏  举报