DirectoryInfo info = new DirectoryInfo(path);
foreach (FileInfo n in info.GetFiles())
然后怎么获取这个文件夹下有多少个文件啊
------解决方案--------------------------------------------------------
info.GetFiles().Length
------解决方案--------------------------------------------------------
- C# code
int count=info.GetFiles().Count();
------解决方案--------------------------------------------------------
DirectoryInfo info = new DirectoryInfo(path);
int count = info.GetFiles("*.jpg").Length + info.GetFiles("*.gif").Length + info.GetFiles("*.png").Length + info.GetFiles("*.bmp").Length;
or
int count = System.IO.Directory.GetFiles("path", "*.jpg").Length + System.IO.Directory.GetFiles("path", "*.gif").Length + System.IO.Directory.GetFiles("path", "*.png").Length + System.IO.Directory.GetFiles("path", "*.bmp").Length;
------解决方案--------------------------------------------------------
DirectoryInfo info = new DirectoryInfo(path);
用info.GetFiles().Length获取文件数
------解决方案--------------------------------------------------------
info.GetFiles()里面可以指定类型的
------解决方案--------------------------------------------------------
- C# code
info.GetFiles().Length