Exclude certain file extensions when getting files from a directory

后端 未结 10 1978
一个人的身影
一个人的身影 2020-12-02 22:00

How to exclude certain file type when getting files from a directory?

I tried

var files = Directory.GetFiles(jobDir);
10条回答
  •  伪装坚强ぢ
    2020-12-02 22:51

    You could try something like this:

      var allFiles = Directory.GetFiles(@"C:\Path\", "");
      var filesToExclude = Directory.GetFiles(@"C:\Path\", "*.txt");
      var wantedFiles = allFiles.Except(filesToExclude);
    

提交回复
热议问题