Download File > Convert to String > Rename

Hi All

I’m using the WaitForDownload activity to download a file, the ‘file’ is then copied to a variable and if I try to move it, I get an error that “System.IO.FileInfo” cannot be converted to String

So what I did was add an assign activity to convert the variable to a string:
strDownloadedFileasString > strDownloadedFile2.Name

But when I try to move the file, I get the following error:

Source: Move File

Message: Could not find file ‘C:\Documents\UiPath\RPA_Test\DownloadedDriver.csv’.

Exception Type: System.IO.FileNotFoundException

RemoteException wrapping System.IO.FileNotFoundException: Could not find file ‘C:\Documents\UiPath\RPA_Test\DownloadedDriver.csv’.
at UiPath.Core.Activities.ScopeActivity.OnFaulted(NativeActivityFaultContext faultContext, Exception propagatedException, ActivityInstance propagatedFrom)
at System.Activities.Runtime.FaultCallbackWrapper.Invoke(NativeActivityFaultContext faultContext, Exception propagatedException, ActivityInstance propagatedFrom)
at System.Activities.Runtime.FaultCallbackWrapper.FaultWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)

Any ideas guys? Even if i ‘move’ it to the same location, I get the same error. Basically if i don’t convert to String, it says I cannot move the downloaded file and if i convert it to string, it says it cannot find the downloaded file :confused:

@steve1977beyond

You can use Path Exists to confirm whether is file is created successfully or not

Then use IF condition, If this is created then use Move File Else give your steps

Also, check you have access to the C:\ with required permissions

Hope this may help you

Thanks

Hey! change the Variable type to System.IO.FileInfo

Regards,
NaNi

Thank you guys, if I use Path Exists it confirms that the file doesen’t exist…except it does. I can see it and it does successfully download.
But I’m unable to do anything with it because the variable is not a string.

With regards to the variable of the downloaded file, this is indeed set to System.IO.FileInfo

Could use the attached code (if using C#) this will give you all the files based on a file mask.

Thank you Jeremy, I’m not very knowledgble with C# though.

So to try and resolve this I have done the following

Capture3

This moves the file to the right location but i want to rename it, so I did this:

Capture4

SKU is the column header in Excel which is referred to earlier in the Flow. However whilst I get no errors, the file then disappears :frowning:

Probably need to add a delimiter to the GetFiles(path, “*.csv”). See if that works.

I say ditch the Wait For Download activity, I’ve found issues with it.

Instead, use a while loop, with the condition: not file.exists(“ C:\Documents\UiPath\RPA_Test\DownloadedDriver.csv”)

Then moving the file should work. Also test to make sure that destination path is correct. If not, that may explain your file “disappearing”