Open file immediately upon download

In the browser, I click on the “download” button and download files, how to open them immediately upon download?
If you use getFile, then there may be an old file

1 Like

@RPA3,

Instead of using download button if you have option to open then do it directly.

If you have downloaded the file to a local folder then try the below link to get the latest file.

Directory.GetFiles("yourDirectoryPath").[Select](Function(f) New FileInfo(f)).OrderByDescending(Function(fi) fi.LastWriteTime).First().ToString

If there was no file of the required format?
But in the folder there were old documents of this format and the robot will take them to work, but you can’t

@RPA3,

Why the old files are there in that folder, move them to a new folder once it is processed.

If the file is not downloaded then you will have a flag, so don’t execute the query to get the latest file.

Unclear. Files are downloaded automatically, without selecting a folder. Nobody will move the old

@RPA3,

The process will pick the latest file to process right, once it is processed successfully move it to a successful folder, else move it to a error folder, Keep the download folder empty.

More? Nothing is clear

Could you tell me how to add to open the Excel file?

@RPA3,

Use “Excel Application Scope” activity to work with a excel file.

Hi
i completely agree with what @sarathi125 suggest
the reason is
–once after downloading the file, if we want to get the latest file downloaded we can use this expression which will surely get the last downloaded file from that folder regardless of file format
Directory.GetFiles(“yourDirectoryPath”).Select(Function(f) New FileInfo(f)).OrderByDescending(Function(b) b.LastWriteTime).ToList(0).ToString

again coming to your point like if no file got downloaded and if you dont want to get the already downloaded file then lets do one thing
–before downloading use a assign activity like this
int_filecount = Directory.GetFiles(“yourfolderpath”).Count
where int_filecount is a variable of type int32

–now once after downloading again get the count
int_afterdownlg = Directory.GetFiles(“yourfolderpath”).Count

now use a IF condition like this
int_afterdownlg > int_filecount
if true it will go to THEN part where we can use this expression to get the filepath
str_filepath = Directory.GetFiles(“yourDirectoryPath”).Select(Function(f) New FileInfo(f)).OrderByDescending(Function(b) b.LastWriteTime).ToList(0).ToString

then can be used or it goes to ELSE part where we can leave it empty so that if no file is downloaded then leave it as it is

and to open the excel file in background pass the file path as input to EXCEL APPLICATION SCOPE
or to open in FOREGROUND pass that file path as input to START PROCESS activity to FILENAME property

Cheers @RPA3

1 Like