How to open recently downloaded Excel file while getting errors?

Hello, in my UiPath sequence, after downloading an Excel file, as a next step I would like to open it. However the name of the excel file will be changed every time the process works so I need to open this file by Assign activity. However it gives error and I cannot move on with my sequence. I would be very appreciated if you could help me about this issue. In the attached image you could find the error I am getting.
20220416_131023

The assign activity code is:
Directory.GetFiles(“C:\Users\zny\Downloads”).Select(Function(f) New FileInfo(f)).OrderByDescending(Function(b) b.LastWriteTime).ToList(0).ToString

@zeynepnaz.yardim can you upload the sequence here?

i tried and assigned
Directory.GetFiles("C:\Users\zny\Downloads").Select(Function(f) New FileInfo(f)).OrderByDescending(Function(b) b.LastWriteTime).ToList(0).ToString
to a string and it works fine

Hello, thank you very much for your rapid reply. I created NewestFile as variable of Arguments. But the main part in this error message is “Non-invocable member” thing I guess… Is it something related to packages like System.IO?

@zeynepnaz.yardim

Try below expression.

NewestFile =  System.IO.Directory.GetFiles("C:\Users\zny\Downloads").Select(Function(f) New FileInfo(f)).OrderByDescending(Function(b) b.LastWriteTime).ToList(0).ToString

Thank you very much for your answer. Unfortunately it didn’t work…

can you try add system.io. before FileInfo as well

system.io.Directory.GetFiles("C:\Users\zny\Downloads").Select(Function(f) New system.io.FileInfo(f)).OrderByDescending(Function(b) b.LastWriteTime).ToList(0).ToString

It didn’t work either…

In here it is written that it can be because of C# language which needs to be converted into VB. Could you please help me about this conversion, if this would be the solution of my problem as well?

if your project is in c# then that explains it

try this it should work

Directory.GetFiles(@"C:\Users\zny\Downloads").Select(f => new FileInfo(f)).OrderByDescending(b => b.LastWriteTime).Select(f => f.FullName).ToArray()[0]

Thank you very very much, this solved the problem!

Finally I also would like to ask you that, this Excel file which will be downloaded is 97-2003 worksheet, so it always gives notification window as “Unless you trust it source… and Do you want to open it anyway?” before opening, which UiPath needs to click “Yes”.

How can I write this command in UiPath because it cannot perceive the Excel file as it isn’t open yet unless clicking “Yes”?

1 Like

you can try use my component
https://marketplace.uipath.com/auth/refresh-session?url=/listings/handle-popups-such-as-update-links-popup

1 Like

Thank you very much! As I’m a beginner, I couldn’t go on with more advanced activities and I handled it with keyboard shortcuts as I realized that the file only needed to press left and enter to be able to open and it worked as well…

Again many thanks for your interest and help,
Best,

1 Like

thats alright, as long as you found a way to solve it :grinning:

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.