How to get the full file path of a specific file and upload the attachment?

Hi all,

I am trying to assign the full file path of a specific file to a variable filepath.
It is a dynamic latest file which I download from a website on a daily basis. The reason why I am going to extract the full file path of the file is because I have to upload the attachment on a daily basis as well in another online form.

I’ve done these but it couldn’t work as I expected:(,
assign folderpath=“C:\Users\rpa01\Downloads”
assign latestattachment=Directory.GetFiles(FolderPath,“.pdf”).OrderByDescending(Function(d) New FileInfo(d).CreationTime).Take(1)
assign FileName=System.IO.Path.GetFileName(latestattachment.ToString)

image
This is how I have to upload the attachment and I am trying to extract the full file path and use 'type into’activity in this.

May I ask how to fix the issue or is there other way to make it happen?

Regards

@RPA_Innovation


Pass the folder path on top and then use another type into and pass the latest filename in filename text box and then click open

Hello @RPA_Innovation
Please refer to the below similar post.

Thanks

Hi @RPA_Innovation

In the first place in your browser you can change the settings to ask where to save before download

Chrome- settings → downloads → ask where to download the file always checkbox

Edge: settings-> downloads → where to save file before downloading

This way while downloading itself you can give the required filepath and the filename together and it would save to that location directly

Or

If you dont want to do this setting… then directly use wait for download activity which will give you the output variable of the file which is downloaded

Use that and get the file location and name directly and use them to move

Cheers

HI @RPA_Innovation

How about this expression?

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

This will get the xlsx files in download folder. Variable Type | String

Regards
Gokul

1 Like

this works perfectly, thank you!

1 Like

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