且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何正确计算文件夹中的文件数

更新时间:2022-12-09 20:28:02

所以这里的问题是 FilesInFolder = dir.GetFiles()。计数计数隐藏文件。即使我设置了Windows文件夹选项来显示隐藏的文件/文件夹,他们没有显示,因为他们是像相册艺术。以下行排序我的问题。

So the issue here is that FilesInFolder = dir.GetFiles().Count was counting hidden files. Even though I've set Windows folder options to show hidden files/folders, they were not shown as they were things like album art. The following line sorted my issue.

FilesInFolder = Directory.GetFiles(FullName, "*.mp3").Count

我想知道,如果有一种方法来计算多个文件类型?例如MP3和WMA?如果有人知道,我会征求意见。

I am wondering though, if there is a way to count more than one file type? I.e MP3 and WMA? If anyone happens to know, I'd apprciate a comment.