How to search excel files in windows explorer

Hello everybody,

I have a case, where I need to search for excel in the windows explorer search area (on the right side).
Do you have any recommendation to do that? (Especially when I need to search for dynamically changed excile files)

Thank you!

Hi @KITES,

try this two, maybe those are fastest solutions:

  1. path Exist activity and pass your path to file to check if it’s exist
  2. if you want to search in windows explorer use powerShell command “ii .” for opening explrer, send hotkey ALD+d to select address bar and type your path

hope this helps! :smiley:

@KITES

Welcome to the UIpath Community.

Try this to find all Excel files from folder and it’s subfolder.

Directory.GetFiles(“FolderPath”,"*.xlsx",SearchOption.AllDirectories)

1 Like

Hi @lakshman in which activity should we write this code? thx

Hi buddy @batuhan @KITES

Welcome to UiPath community
Thats a good question to start with
Fine
In order to search for files of particular type in a folder or in a directory including all its sub directory and if the file name is not know except the file type (.xlsx) we can use this dot net method to accomplish this
The basic syntax is this
public static string[] GetFiles (string path, string searchPattern, System.IO.SearchOption searchOption);
Where
–String path = the folder path, that is the directory we want to search
–String search pattern = pattern here for us is “*.xls” (this will include both .xls and .xlsx) where * is a wild card tgat we can use if we are not sure about the file name but still clear with the file type
–searchoption = its added arguments to mention whether to chevk in all of its subfolder or not

This is one of the overloads of GetFiles method and for more on this

So here in our studio we need to mention this in a assign Activity like this
*Out_filepatharray = Directory.GetFiles(“yourfolderpath”,".xls", System.IO.SearchOption.AllDirectories)

Where Out_filepatharray is a variable of type array string
To get the value of file path as a output we need to either mention in any activities like this
Out_filepatharray(0). ToString
Where 0 is the index of the first value in the array
Or we can pass this variable Out_filepatharray to a activity called For each loop and change the type argument as string in the for each loop property
And inside use a write line Activity and mention the input as item.ToString where item is the variable that gets each value from the arrau of string passed as input to the for each loop

Thats a buddy you are done
Hope this would help you
Cheers @batuhan @KITES

@batuhan

Welcome to the UIpath Community.

Use Assign Activity and write the above expression in right hand side. The output of this expression is array of String. So, create one array of string variable and place it in left hand side.

thank you!

1 Like