How to check whether the latest file has been downloaded or not

HI Community,

Let me explain the scenario.
After completion of certain activities one file should be downloaded . Based on whether the file has been downloaded or not I need to execute further steps.
Even if the file is downloaded, the file name changes in each run.
So, I need to check whether the the required file is downloaded or not. Please suggest some sol.


@siddhi ,
You can Use “Path Exists” Activity


It will return a Boolean variable true or false based on that you can continue with the if condition


But it will return true if some old file is present in that , right!!
I need to check whether the latest file is downloaded or not.


@siddhi ,
Yes . But the “FileName” is Unique for the one which is latest and the old one isn’t it?

Anyhow to get the Latest file from the downloads folder you can use below method.

Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)+"\Downloads").[Select](Function(x) New FileInfo(x)).Where(Function(f) f.Extension.Equals(".pdf")).OrderByDescending(Function(x) x.LastWriteTime).Take(1).ToArray()(0).ToString

Note : I have asumed the file is PDF .You can change the file extension acordingly.


Hi @siddhi
Try this
str_filepath = Directory.GetFiles(yourfolder_path,“*.txt”).OrderByDescending(Function(d) New FileInfo(d).CreationTime).Tolist(0)

Hi @siddhi

1. Assign activity:
   - Variable: folderPath
   - Value: "C:\Path\to\Specific\Folder"

2. Get Files activity:
   - Folder: folderPath
   - Output: filePaths

3. For Each activity:
   - Values: filePaths
   - TypeArgument: String
   - Body:
     - If activity:
       - Condition: File.GetCreationTime(item) >= DateTime.Now

       -- True branch --
       4. Message Box activity:
          - Message: "New file found: " + item

       -- False branch --
       5. Message Box activity:
          - Message: "File not new: " + item

6. End of workflow

Hope it helps!!


Use the Wait for Download activity.

It waits for any file to be added to the target folder, and gives you a FileInfo variable back so you can then check the path, filename, etc

facing this issue, please suggest.


@Jithesh_R @lrtetala
Using this method , m getting the file name which is latest.

But in my case sometimes the file is getting downloaded or sometimes not. So your method works in only if the file is downloaded.
but when file is not downloading then also this method retrieves the last downloaded file which is wrong. Bcoz based on whether the file is getting downloaded or not after performing some activities, I need to perform other actions too.

So can you please suggest me on it.


I would say you can use a wait for download activity.
This will wait for a download specified in a specific path, and if the file is downloaded it will also depends on how this file is getting inputted into your workflow. Linq queries work good but you can also use a foreach folder activity and configure it to what you need based on the conditions you set in the properties. Then you are able to use a check if file exists activity which outputs a boolean, and based on this condition of the boolean then you can also configure your workflow based on that. let me know if this has helped :slight_smile:

You can use “file exist” activity:

If you know the name of the file or if you can predict what the file will be named you can do it as a variable.

1 Like