Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exclude certain file extensions when getting files from a directory

Tags:

c#

file

directory

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

I tried

var files = Directory.GetFiles(jobDir); 

But it seems that this function can only choose the file types you want to include, not exclude.

like image 923
Graviton Avatar asked Apr 16 '09 08:04

Graviton


People also ask

How do I exclude a file type in Windows Search?

On the “Indexing Options” window that opens, click the “Advanced” button. On the “Advanced Options” window, click the “File Types” tab. In the “File Types” tab, you see all the file formats that Windows currently displays in its search results. To exclude a file type from the index, deselect that type in the list.

How do I search for all files with specific extensions?

For finding a specific file type, simply use the 'type:' command, followed by the file extension. For example, you can find . docx files by searching 'type: . docx'.

What is an exclude file?

Excluded files in DeployHQ are files that you need to store in your repository, or that might be generated within a build pipeline but not upload to your server. This might be useful for certain files within your app that you want to version control but not actually deploy.

What is exclude folder?

If you trust a file, file type, folder, or a process that Windows Security has detected as malicious, you can stop Windows Security from alerting you or blocking the program by adding the file to the exclusions list.


1 Answers

You should filter these files yourself, you can write something like this:

    var files = Directory.GetFiles(jobDir).Where(name => !name.EndsWith(".xml")); 
like image 151
okutane Avatar answered Oct 11 '22 12:10

okutane