Hello. In my UiPath workflow, I have constructed an automation able to screenshot data and download csv files through a few clicking activities. However, I only have one problem left, I could not save/move the downloaded csv files into a specific folder. Furthermore, I am unable to make any connections with any Microsoft app as I have no admin access to my current account. I am considering using coordinated clicks but I currently have it as my last option, does anyone have any ideas?
Use Move file activity to move the file to the desired folder. No need of any other applications.
Use this linq in assign activity to get latest file in a folder
Dim latestFile As FileInfo = (From f In New DirectoryInfo("C:\Your\Folder\Path").GetFiles()
Order By f.LastWriteTime Descending
Select f).FirstOrDefault()
Sorry but I have not use linq before, am I supposed to write it on an expression editor?
@Justin_Tan_Jun_Song_EE
you can also use below sequence to solve your problem.
Wait for Download activity helps with large files or slow network as it will wait till the download complete, otherwise you will get error while moving file.
No worries
You only have to paste what’s after the =
Assign Left: Your variable (latestFile)
Assign Right: (From f In New DirectoryInfo(“C:\Your\Folder\Path”).GetFiles()
Order By f.LastWriteTime Descending
Select f).FirstOrDefault()
If LatestFile is a string, you might need to add a .FullName at the end (example below)
If LatestFile is of FileInfo, you dont need to add anything else
Left:
Right:
Remeber the datatype of variable LatestFile
should be FileInfo
Use code like this
Output:
Thank you very much, it worked! Apparently having latestFile as string is better as “Move File” activity is compatible with string. But still, thank you all who helped!
Just a question though, since this is only for one section of my project, is it advisable that I copy and paste these two activities for the rest of the sections
I would suggest to create a another workflow with these 2 activities.
Pass required arguments and reuse same workflow where you need it. By this way your code will be better testable and maintainable.
since I have around 50+ sections for my project, I need to copy and paste around 50+ times. Won’t it lag my project (Sorry for asking, last time did workflow in workflow and my computer could not handle)
It should not be issue, it’s standard procedure in UiPath development.
Instead of copy pasting these activities at all the location wherever needed, just create a workflow, put these activity in that and just invoke this workflow anywhere you needed this functionality.
This will make your code modular and easy to maintain!
Hello, sorry to bother you again. I am wondering whether there is anything I can add in the VB code for the “Move File” activity to rename the file after moving?
Just pass the new name you want as destination file in move file method and it will move the file with that name.
For example
sourcePath = “C:\MySourceFolder\oldFileName.txt”
destinationPath =“C:\MyDestinationFolder\newFileName.txt”
Just pass these variables in the activity.
Got it to work, thank you so much!
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.