读取服务器或者本地的文件夹下面的文件

public class UnitTest1
    {
        [Fact]
        public void Test1()
        {
            List<string> array = new List<string>();
            DirectoryInfo theFolder = new DirectoryInfo(@"G:\检验批测试\");
            DirectoryInfo[] dirInfo = theFolder.GetDirectories();
            //遍历文件夹
            foreach (DirectoryInfo NextFolder in dirInfo)
            {
                // this.listBox1.Items.Add(NextFolder.Name);
                FileInfo[] fileInfo = NextFolder.GetFiles();
                foreach (FileInfo NextFile in fileInfo)  //遍历文件
                    array.Add(NextFile.Name);
            }
        }

    }

 

posted @ 2019-06-25 17:42  昵称已存在嘿  阅读(1053)  评论(0编辑  收藏  举报