Illegal characters

Hello,

How do I copy a file if the path is for instance? “\Aasv081\ml_17576$\TMP\nezivot.xml”
Because the UiPath error window shows: Copy file : Illegal characters in path.

Moreover, the strange thing is that when I use the path as fixed value it is working, but when I use it as an variable, this error pops up.

Thanks a lot in advance.

1 Like

Not sure if it fixes anything, but check if you get the same error if you replace"\" with "\\" in your variable.

Or filepath.Replace("\","\\")

Hi
I’m Kyunghoon

I have the same error.
The replace method is the same.
I declare a variable to perform assign but it is the same
Is there any solution?

Hi @goldpapa,

use this code to remove illegal characters from the path.

System.Text.RegularExpressions.Regex.Replace(unCleanString, @"[\\/:*?""<>|]", string.Empty).Trim()

Regards,
Arivu

3 Likes

Hi arivu96!
thank you for telling me.

Now I know, I need to remove illegal characters!

Hello vvaidya,

is there any other way? I need the path to stay the same, I cannot really replace characters in the path as I wont get the exact file I am looking for. Please help.

Thanks

Hello,

Is there any way to catch or deal with this error?

Hi @arivu96

How do you use:
“System.Text.RegularExpressions.Regex.Replace(unCleanString, @”[\/:*?""<>|]", string.Empty).Trim()"

Would you just use the Assign activity? I am not having any luck.

Any help would be appreciated.

Cheers

Steve

You need to remove the “@” before the string of illegal characters. I did, and it worked from there.

And yes, you use the assign activity, like this:

So like this: System.Text.RegularExpressions.Regex.Replace(strFilthyPath,"[/:*""’?¿<>|]",string.Empty).Trim

2 Likes