Check file\folder

Good morning I created a process with UiPath that checks the existence of a file or a folder,
and everything works.

The problem is that every day the file you need to check your identity, every day is created with a name given by a prefix and then by the time stamp.

So the name of the file to check will change every day how can I do?

PS: This file is generated by another software and not by UiPath.


1 Like

One approach would be to replace the timestamp in the filename each day.

System.IO.File.Exists("directory\SourcesRepository "+Now.ToString("yyyy-MM-dd hh;mm;ss")+" (Completo)")
1 Like

The time will be different, so you can also take this approach to use .GetFiles()

System.IO.Directory.GetFiles("directory", "SourcesRepository "+Now.ToString("yyyy-MM-dd")+"*(Completo)").Count > 0

You can try following steps:

  1. Get all the files from the folder. Directory.GetFiles(“FolderName”)
  2. Run loop on the first step.
  3. Check if file name contains "now.ToString(“yyyy-MM-dd”). If yes then this is the file which you are interested in.

@RiccardoWKGRP I think @ClaytonM’s solution is to be used in an if activity, not a path exists activity.

If .Get files is greater than 0 (meaning it exists)

1 Like

ok, but I think I did not understand how to do it

now I understand how to do it but it always turns out that the file does not exist

Hi, can you show how you did it with screenshot? Also, you might need the extension on the end of the pattern like: “SourcesRepository “+Now.ToString(“yyyy-MM-dd”)+”*(Completo).zip”

That pattern should match the file you are looking for with the “*” (wildcard) representing the time as hh:mm:ss

You can also place the .GetFiles().Count.ToString in a message box or write line to check how many were found, or use .GetFiles()(0) to look at the first item in the list.


can you post a screenshot for the same?