jjzjj

EnumerateFiles

全部标签

c# - Directory.EnumerateFiles 异常

我有一个非常罕见的行为。我正在使用Windows10x64和VisualStudio2013,当我在32位应用程序中运行此代码时Directory.EnumerateFiles(@"C:\Windows\System32\winevt").Count()我有一个System.IO.DirectoryNotFoundException类型的异常如果我打开一个非管理员cmd控制台并运行dirC:\Windows\System32\winevt结果是winevt文件夹中的文件夹列表。该文件夹存在并具有子文件夹。有什么想法吗?谢谢 最佳答案

c# - 从包含大量文件的目录中检索文件

我的目录包含近14,000,000个*.wav格式的音频样本。所有普通存储,没有子目录。我想遍历文件,但是当我在该文件夹上使用DirectoryInfo.GetFiles()时,整个应用程序会卡住几分钟!这可以用其他方式完成吗?也许读取1000个,处理它们,然后再读取下一个1000个等等? 最佳答案 你试过了吗EnumerateFilesDirectoryInfo类的方法?正如MSDN所说TheEnumerateFilesandGetFilesmethodsdifferasfollows:WhenyouuseEnumerateFil

c# - 从包含大量文件的目录中检索文件

我的目录包含近14,000,000个*.wav格式的音频样本。所有普通存储,没有子目录。我想遍历文件,但是当我在该文件夹上使用DirectoryInfo.GetFiles()时,整个应用程序会卡住几分钟!这可以用其他方式完成吗?也许读取1000个,处理它们,然后再读取下一个1000个等等? 最佳答案 你试过了吗EnumerateFilesDirectoryInfo类的方法?正如MSDN所说TheEnumerateFilesandGetFilesmethodsdifferasfollows:WhenyouuseEnumerateFil

c# - 如何使用多个条件过滤 Directory.EnumerateFiles?

我有以下代码:Listresult=newList();foreach(stringfileinDirectory.EnumerateFiles(path,"*.*",SearchOption.AllDirectories).Where(s=>s.EndsWith(".mp3")||s.EndsWith(".wma"))){result.Add(file);}它运行良好,可以满足我的需求。除了一件小事。我想找到一种更好的方法来过滤多个扩展。我想使用带有过滤器的字符串数组,如下所示:string[]extensions={"*.mp3","*.wma","*.mp4","*.wav"};

c# - Directory.EnumerateFiles 与 Directory.GetFiles 之间有什么区别?

Directory.EnumerateFiles与GetFiles有什么区别?很明显,一个返回数组,另一个返回Enumerable。还有什么吗? 最佳答案 来自thedocs:TheEnumerateFilesandGetFilesmethodsdifferasfollows:WhenyouuseEnumerateFiles,youcanstartenumeratingthecollectionofnamesbeforethewholecollectionisreturned;whenyouuseGetFiles,youmustwa