海底鱼叉男,英雄之轮,大型游乐设备
1 string path="指定路径"; 2 3 string filename =“需要查找的文件名.csv"; 4 5 list<string> linestringlist = new list<string>();//存储所有读取到的文件 6 7 directoryinfo[] datedirarr = new directoryinfo(path).getdirectories(); //取指定路径下的所有目录 8 9 foreach (directoryinfo directoryinfo in datedirarr) 10 11 { 12 string fullname = filepath + directoryinfo.name + "\\" + filename; 13 if (!file.exists(fullname)) 14 { 15 continue;//目录下不存在此文件,返回。 16 } 17 fileinfo file = new fileinfo(fullname); 18 streamreader reader = new streamreader(file.fullname); 19 while (!reader.endofstream)//判断是否读取完成 20 { 21 linestringlist.add(reader.readline()); 22 } 23 reader.close(); 24 25 }
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
Net Core Web Api项目与在NginX下发布的方法
asp.net core3.1 引用的元包dll版本兼容性问题解决方案
IdentityServer4实现.Net Core API接口权限认证(快速入门)
ASP.NET Core MVC通过IViewLocationExpander扩展视图搜索路径的实现
网友评论