# Filtering files in a folder

**URL:** <https://forum.uipath.com/t/filtering-files-in-a-folder/299073>\
**Category:** Studio\
**Tags:** activities-panel, question, studio, excel, system, activities\
**Created:** [March 17, 2021, 10:59pm UTC](https://forum.uipath.com/t/filtering-files-in-a-folder/299073 "2021-03-17T22:59:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon86233825](https://avatars.discourse-cdn.com/v4/letter/a/ac91a4/32.png) [@anon86233825](https://forum.uipath.com/u/anon86233825)\
**Post date:** [March 17, 2021, 10:59pm UTC](https://forum.uipath.com/t/filtering-files-in-a-folder/299073/1 "2021-03-17T22:59:08Z")

</div>

I want to filter .xls files in a folder and I use this filtering option and it doesn’t work. Can anyone help me on this?

---

<div class="post-metadata">

**Author:** ![ppr](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ppr/32/464097_2.png) [@ppr](https://forum.uipath.com/u/ppr)\
**Post date:** [March 17, 2021, 11:21pm UTC](https://forum.uipath.com/t/filtering-files-in-a-folder/299073/2 "2021-03-17T23:21:09Z")

</div>

@anon86233825

have a look on following statements:

Directory.GetFiles(“YourDirPath”, “\*.xls”)  
will filter for files with extension xls and returns a strring array with the found filenames

> **[Directory.GetFiles Method (System.IO)](https://learn.microsoft.com/en-US/dotnet/api/system.io.directory.getfiles?view=netframework-4.6.1)**
>
> Returns the names of files that meet specified criteria.

Path.GetExtension(“C:\test\abc.xls”)  
will return: “.xls” - including the . the dot is missing in your statement

> **[Path.GetExtension Method (System.IO)](https://learn.microsoft.com/en-Us/dotnet/api/system.io.path.getextension?view=netframework-4.6.1)**
>
> Returns the extension of a file path that is represented by a read-only character span.

Maybe there is a missmatch between upper and lower case and can be fixed by  
System.IO.Path.GetExtension(file).toUpper.Equals(“.XLS”)

---

<div class="post-metadata">

**Author:** ![Eric\_Wong\_Test](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/eric_wong_test/32/186916_2.png) [@Eric\_Wong\_Test](https://forum.uipath.com/u/Eric_Wong_Test)\
**Post date:** [March 18, 2021, 8:33am UTC](https://forum.uipath.com/t/filtering-files-in-a-folder/299073/3 "2021-03-18T08:33:14Z")

</div>

May be using Contains  
System.IO.Path.GetExtension(file).Contains(“.xls”)

---

<div class="post-metadata">

**Author:** ![Hiba\_B](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/hiba_b/32/524496_2.png) [@Hiba\_B](https://forum.uipath.com/u/Hiba_B)\
**Post date:** [March 18, 2021, 8:39am UTC](https://forum.uipath.com/t/filtering-files-in-a-folder/299073/4 "2021-03-18T08:39:29Z")

</div>

Inside the Equals I think that you need a point before the extension (“.xls”)

---

<div class="post-metadata">

**Author:** ![Vrushali\_Gave](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/vrushali_gave/32/176750_2.png) [@Vrushali\_Gave](https://forum.uipath.com/u/Vrushali_Gave)\
**Post date:** [March 18, 2021, 8:48am UTC](https://forum.uipath.com/t/filtering-files-in-a-folder/299073/5 "2021-03-18T08:48:31Z")

</div>

@anon86233825 You try this also

Directory.GetFiles(“C:\Documents\folder1”,“\*.xls”)

Use for each loop activity and perform the rest of the activities in the for each loop one bye one

Best Regards,  
Vrushali
