Copying & Renaming file problem

Hey guys,
I faced the problem with copying and renaming file.
-Robot receives multiple emails with multiple invoices.
-downloads attachments
-renames files and sends them into folders

The problem is that while copying and renaming i receive Error: The given path’s format is not supported…
80% all works fine, but with specific email and it’s attachments error is occured.

Currently recieve error with file name: ארוחות מכתשים איירפורט 9.19 108033
to be copied with name: 1:08033-y#עידית לוגיסטיקת מזון#.pdf
Any ideas what going on here?

Hi Slavich,

In the File name some special characters will not allow.

“:” - this is not allowed, so try replacing this with other character and try.

Hope this might helps you


1 Like

But when I do renaming with “:” with hands - it allows…

use string operations

like Yourstring.replace(“:”, “-”)


What about
Copy and rename from :

The same Error…

This looks good, are you getting exception with this? What exception you are getting? Try by copying to a different folder instead of trying within the same folder.

I recieve
Error: Illegal characters in path…
even when I copy to other folder.

Hi @Slavich

A couple of things I like to do is

  • Make sure that the path + filename length doesn’t exceed the default windows max

yourFilename.count > 260

  • Strip any invalid windowns characters

validFilename = regex.replace(yourFilename, path.GetInvalidFileNameChars(), “-”)

or whatever you want to replace with.

1 Like