Open the downloaded excel file


I would like to open automatically the excel file downloaded. The excel file has a different file name every time it is downloaded (It’s a generated report from an intranet web application).

Thank you


As you can see, UIPath doesn’t allow me to create a variable with the given expression

Thanks a lot for your help.

change the Fil variable type from string to array string system.string[]

UIPath still outputs the same error…

please upload the workflow.

The workflow won’t work for you because the first thing it does is accessing an intranet web application…

np. I just want to see the workflow and why the error prompting.

Try like this:
string[] yourVar = Directory.GetFiles(downloadsFolder).Where(Function(x) new FileInfo(x).CreationTime.Date = DateTime.Today.Date).ToArray()
Or if you want just the newest one:
string newestFile = Directory.GetFiles(downloadsFolder).Where(Function(x) new FileInfo(x).CreationTime.Date = DateTime.Today.Date).First()

Also note that for these kind of expressions it’s usually better to put them in an Assign activity instead of deafult value for a variable (as it get’s messy to debug/handle errors if f.e. location is unreachable and throws an IO exception).


Thank you for your answer it really helped me. But if you want the newest file, the request you wrote will not work, it gives the first file found on the list (An alphabetically ordered list).

Here’s an expression that works for this case :
Directory.GetFiles(pathDownload).OrderByDescending(Function(f) New FileInfo(f).LastWriteTime).First()

EDIT : The expression I gave will sort files by last write time, meaning that if one of the files was modified, then the recent file will be the modified file. Which wasn’t the use case I wanted.

The expression to use in this case (If you want the recent file bu creation time, not by modification time ) is :
Directory.GetFiles(pathDownloads).OrderByDescending(Function(f) New FileInfo(f).CreationTimeUtc).First()


can you tell me where i have to give this expression.

You have to put it in a variable


I am trying to read recently generated excel file. I have created variable and given expression to that variable like “Directory.GetFiles(downloads).OrderByDescending(Function(f) New FileInfo(f).LastWriteTime).First()”.
and in read range activity , i am giving this variable name. I am stuck here. could you please help.

Whats the error.
Could you upload the workflow?

Error - CompareExcel : Value cannot be null.
Parameter name: path Main.xaml (20.1 KB)

Every time i run my workflow, its generating new excel file with time stamp. so i want to read recently generated file.

did you sort out this issue?
This is strange .
Please pass full path in Directory.GetFile(“FullPath”)
Its throwing when i pass variable.

Directory.GetFiles("“C:\Users\vreddapp\Desktop”").OrderByDescending(Function(f) New FileInfo(f).LastWriteTime).First()

Check now.Main (28).xaml (21.7 KB)

I am able save the file in date time format each time i run the workflow. But issue is how to read the recently generated file.

when i tried running the workflow i am getting this error “Read range : Object reference not set to an instance of an object.”

It’s working fine for me.
Put one msg box and pass File variable to see is it taking recent file. Then you could pass to read range activity.(looks like its returning empty item)