Copy file from one folder to another


I am trying to have UiPath search for a file on a Shared Drive and move it to another location. The location on the shared drive where all files might be is the same every time. But the file that needs to be looked for each time differs. The name of the file can be something like “AB1234 00567”.
Now I am reading from another csv that a file needs to be searched and that the file shall have its name in 2 parts - AB1234 and 00567. Now the problem is, on shared drive, this file may not have the exact same name. Sometimes, the 00 of the 00567 could be skipped. First part however is the same.
So, in “Copy file” activity, how can i specify a dynamic path? Something like, Path: Z:\ Shared Drive\ “AB1234” + contains.(237)?

Please help.Thanks.

Hey bro. I think you can use a wildcard in the .GetFiles() function.

I’m assuming you know what both parts are in a variable, so here is an example:

filesearch = System.IO.Directory.GetFiles(folderpath, "*"+part1+"*"+part2+".CSV")

However, if part2 is always a number, then you might need to convert it to remove the leading zeros.
Like this:

filesearch = System.IO.Directory.GetFiles(folderpath, "*"+part1+"*"+If(IsNumeric(part2),CLng(part2),0).ToString+".CSV")

This will return an array, so you want to check that you found files before using the array.

If filesearch.Count > 0
   Copy File // using filesearch(0).ToString

I hope this answers it for you.
Hit me up tonight if you still can’t get it working.



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