File exists

Hello everyone, I would like to ask if it is possible to find if there is any excel file included in the project that I am trying to develop in Uipath.

I only want to know if there is any file, in case it is I know what to do, in case there is not I know what to do also. But I dont know how to check if there is any file inside the project no matter the name of that file(important is to be an excel file).
I already used Path exists but Path exists asks me for the name of the file, I want to do it like smth general ( if there is or not any excel file in the project).
Any idea if this is possible?


You can use the Directory.getFile(“Input path”,“*.xlsx”) for validating the presence of file in you folder

Hi @Xheni_Xhensila

You can try this

Directory.GetFiles(Environment.CurrentDirectory, "*.xlsx", Searchoption.AllDirectories)

this will give you an array of string (full path of excel files), if present in your project directory which is your current directory else an empty array

1 Like


Try like this

Assign strFolderPath = "Desktop\InputFolder\"
Assign arrFiles = Directory.GetFiles(FolderPath,"*.xlsx")

Take one for each row

You will get the xlsx file if found inside the folder…


hm and the Directory.GetFiles… where should I write it, I mean I need to fulfill these two fields of File exists. Should I write the line that you suggested in the first field of file path?


Try the above expression. there you no need to specify the file name


ok, but before doing this I have to declare as a string FolderPath using an assign activity right?
strFolderPath = "Desktop\InputFolder\"

The idea is that I am not sure what path to add as per the excel file will be inside the project and furthermore if this will give problems in the moment that Users will do run from the Assistant. Users have nothing to do with this excel file but I need it to be inside the project as per I am using it because I need it to make some other manipulations in my project.

I am trying this solution also Kumar, could you provide me some more information about this please? This is what I get when I use the code

The error says that: Value of type ‘1-dimensional array of string’ can not be converted to ‘String’

Hi @Xheni_Xhensila

Please refer this xaml

FileExists.xaml (6.1 KB)

Kumar thank you,

I am trying to implement your solution based on my needs.

How can I delete it in case the file with TodayDate does not exists.
I am expecting to have the excel like this

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.