Checking For Files Inside Local Machine Directory




I’m trying to automate a task that checks if one or more files exists inside an already specified folder in my local machine, and if they do exist, put all of the files inside a DataTable, much like how Enumerate Files in ftp works, and email them one by one.

Path Exists seems to return only a boolean, so no dice there. Any advice?


To check file exist you can use this.
System.IO.File.Exists("Path) in an IF activity to check whether the file exists.

To get files from the specific folder
Directory.GetFiles(folderPath) that returns an array of strings with absolute paths to all files in that folder then Use ForEach Loop to iterate through all the files.


Thanks for the response.

I want to email all files that happen to exist inside that folder. As such, I wouldn’t know their file paths. They’re just there. How would I check if a directory is empty or it has files?

If I put the following in an IF Activity, does this work?:

Directory.GetFiles(“path”) != null

Then: Do Directory.GetFiles(“path”), then For Each, email, etc etc

Else: Delay Activity, check again

Also, which activity would I use to retrieve files using GetFiles and return an array of strings?


Give a try.:thumbsup:
Use assign activity where LHS is array of string variable which holds all the files.
Here is for the mail part.
attaching multiple files in a mail


Managed to get it to work!

Thanks so much for your help!


I used System. IO. File. Exists (“path”) to check whether the folder contains any files… But even if there are files it returns a no exist message… What can I do?


@saniyaka, Other way would be,

Reference : (This is only for .Xlsx files change it as per your requirement )

Get the files count from a particular folder

Dominic :slight_smile: