GetFiles()怎么获取这个文件夹下一共有多少个图片啊?
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