How to check on file downloaded of specific format and perform next activities

Hi Everyone,

I am trying to download a file from browser but when the file is saving to my local it is getting saved with dynamic name and .zip extention(for ex: filenameYYYYMMDDHHMMSS.zip) to a specific folder. I need to wait until his file gets downloaded and perform the next activities.
If we know the downloaded file name then we can use “PathExist” option to validate and continue but here in my case I will not be knowing the file name until download is completed.

Can anyone assist me on this issue.
Many Thanks in advance.

Venu

Force the download to go to an empty directory, and only get that file. Then you can manipulate it. Just make sure that the directory is empty when you’re done identifying and working with it.

Hi Anthony

Thank very much for quick response and suggestion. I will check the above option but during download the file extension will be something like “.crddownload” and after download completion it will be “.zip” format.
How can we know when this file changes to .zip extension.because when we move file to empty directory then it will have only this file but how to confirm this is zip format file.
Request to please share some logic activity if you have time.
Thank you very much for support.
Venu

While I don’t have a workflow example, what you can do is use browser navigation activities (Click, Type Into, etc.) to get the download, and then to tell that it’s completed, write a While loop after you’ve started the download. Essentially, you’ll be in the loop until the download is complete. The condition for the While loop will look like this:

System.IO.Directory.GetFiles(DownloadDir, "*.zip").Count <= 0, where DownloadDir is the string representing the path where you’re downloading the file.

The logic gets a count of all files in the directory ending in “.zip”. Since there should only be 1 file in the directory, the While loop will continue iteration until the file is downloaded. After that, you can begin handling the file.

You may also consider putting a Delay activity with a 1 second (or less) timer on it to keep this process from checking so often that it overuses resources. This slows down detection of finding the file, but otherwise, the machine checks the count as fast as it possibly can, which can drain resources quickly.

1 Like

@venu_gopal1

but here in my case I will not be knowing the file name until download is completed…`

When downloading file from browser, you should use Save As option, then you can assign path for the download file .

1 Like

Hi Anthony

Thank you very much. It worked.

Regards
Venu

Hi Doanh

Thank you for assistance. @Anthony_Humphries Logic worked for me in checking the downloaded file and moving to another location to make download location empty all the time. However, I verified in my application and I cannot see “Save As” option and am using Google Chrome.

In my application, when I click on Download option, It will prepare the file and keep it ready to download . To achieve download, I am using “Wait Element Vanish” option to click on the final download button. But my logic is getting failed after certain time , It is falling due to timeout exceeded .

@Anthony_Humphries and @Doanh : Any advise to handle this situation. Below is the screenshot. I am very new to RPA actually .

Google Chrome saves to the Downloads directory by default. You’ll need to change the way Chrome saves downloads so it asks where you want to save files.

in chrome, you need to change setting of chrome

Change download locations

You can choose a location on your computer where downloads should be saved by default or pick a specific destination for each download.

  1. On your computer, open Chrome.
  2. At the top right, click More More|Autox18 and then|autox18 Settings .
  3. At the bottom, click Advanced .
  4. Under the “Downloads” section, adjust your download settings:
  • To change the default download location, click Change and select where you’d like your files to be saved.
  • If you’d rather choose a specific location for each download, check the box next to "Ask where to save each file before downloading.

Hi
Thank you for above input. I did the changes but however i need to wait on the page untill “files are being prepared” element to vanish then only download button will be enabled.
As I used “Wait Element Vanish” , to wait until file is prepared for download, after certain time period it is throwing exception stating that " Activity Timeout Exceeded". I can do the above changes only after I click on download button which will be appeared on screen when it is completely prepared to download.

Many thanks in advance for your quick assistance.

Regards
Venu

For this, you’ll need to increase the Timeout period in the Wait Element Vanish activity. Set it to some length of time (in milliseconds) which will typically be longer than the time it takes for the download link to appear.

1 Like

Thank Anthony and Doanh. It worked :slight_smile: thank you very much for assistance and solution

1 Like

I have created a custom workflow “WaitForDownloadToComplete” for my use.
You can call it after download is initiated and it waits till file is downloaded.

It accepts an IN argument only i.e “FileFullPath”.
You have to pass full path of file for example “C:\Users\User\Documents\UiPath\IsFileDownloaded\20MB.zip”

and it waits till file is downloaded fully.

Please refer to attached workflow XAML file

WaitForDownloadToComplete.xaml (8.5 KB)