---
title: "Can you call Directory.GetFiles() with multiple filters?"  
description: "Can you call Directory.GetFiles() with multiple filters?"  
author: "Anonymous User"  
published: 2013-11-14  
updated: 2013-11-14  
canonical: https://www.mindstick.com/forum/1743/can-you-call-directory-getfiles-with-multiple-filters  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# Can you call Directory.GetFiles() with multiple filters?

I [am trying](https://answers.mindstick.com/qa/36834/which-two-programming-languages-should-i-master-in-if-i-am-trying-to-get-into-google-or-facebook) to use the Directory.GetFiles() [method](https://www.mindstick.com/forum/166/webservice-method) to [retrieve](https://www.mindstick.com/forum/34400/how-to-retrieve-form-values-in-controller-action) a list of [files](https://www.mindstick.com/articles/23302/the-importance-and-advantage-of-keeping-your-important-files-on-the-cloud) of [multiple](https://www.mindstick.com/blog/12797/iowa-is-expected-to-see-heavy-growth-in-multiple-sectors) types, such as mp3's and jpg's. I have tried both of the following with no luck:

Directory.GetFiles("C:\\[path](https://www.mindstick.com/articles/44333/4-expert-tips-on-how-to-pick-the-right-career-path)", "*.mp3|*.jpg", SearchOption.AllDirectories);

Directory.GetFiles("C:\\path", "*.mp3;*.jpg", SearchOption.AllDirectories);

Is there a way to do this in one call?

## Replies

### Reply by Anonymous User

Hi Pravesh,\
You can try this:var files = Directory.GetFiles("C:\\path", "*.mp3", SearchOption.AllDirectories).Union(Directory.GetFiles("C:\\path", "*.jpg", SearchOption.AllDirectories));

\


---

Original Source: https://www.mindstick.com/forum/1743/can-you-call-directory-getfiles-with-multiple-filters

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
