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)
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?
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
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