csharp 查找并过滤目录中的文件

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了csharp 查找并过滤目录中的文件相关的知识,希望对你有一定的参考价值。

 //grab all files in directory and filter them by using the extensions               
  string[] extensions = { ".xml", ".raw", ".img", ".bin", ".cor", ".sgf" };
  
  //linq query to get files, change SearchOption accordingly
   var files = Directory.EnumerateFiles(hsFolderPath, "*.*", SearchOption.TopDirectoryOnly)
                    .Where(s => !extensions.Any(ext => ext == Path.GetExtension(s))).ToList();

以上是关于csharp 查找并过滤目录中的文件的主要内容,如果未能解决你的问题,请参考以下文章