Replace double Backslashes with a single Slash - wrong behaviour

I want to use a Windows path. But any time I save a Windows Path to a usual UiPath variable, it is always replaced by a double quote.

For example:
"C:\some\path\to\a\file.txt"
is replaced by
"C:\\some\\path\\to\\a\\file.txt"

In usual VB.net it is not changed in that way. I also tried to use the replace activity. But after replacing "\\" with "\" it always replaces it with double backslashes. I’m confused about that behaviour. Is this anything good for a simply a bug?

By the way. When I use Strings directly without saving to a variable it also works. So let’s say I have a variable with the value: "C:\\some\\path\\to\\a\\file.txt" and I use it directly in an activity via "C:\\some\\path\\to\\a\\file.txt".ToString.Replace("\\","\") it works. But in my case I need it directly in the variable.

Hi @kwoxer,
Can you show the example of that variable and eventual use case (project/workflow)?

I think it’s just a visual issue. Somehow now when I try to access the folder or create a new one with the double quoted String, it works. Maybe I had a mistake in my process.

Anyway why is a backslash always doubled? It seems that internally a signle backslash is used.

Anyway I just ignore the double backslash now and continue as if it’s a single one. :slight_smile:

1 Like

Anyway just to investigate a little. Could you tell me which version of Studio do you have?

2019.8.0 - 8/29/2019
Community Edition
EXE Installer

License Provider: Orchestrator
Device ID:

Update Channel: Stable

Microsoft Windows 10 Enterprise 64-bit
.NET Framework Version 4.7.2 or later

1 Like

Thank you very much. Last thing I forgot. Could you please paste a little simple example of workflow where such thing occurs?

By the way. The background is that I save config to a json file. And there you cannot save single backslashes in. So I escape them there with another backslash. And in UiPath I tried to clean that Path. But as already said it’s somehow just a visual bug of UiPath. It works with double slashes.

Steps to reproduce:

  • create String variable with "C:\test\path"
  • Debug with Step into and see that it’s set to "C:\\test\\path" in the locals
1 Like

Thank you for sharing that. I will take a closer look on it :slight_smile:

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

Hi @kwoxer,
Sorry for very very late response. I finally got answer to this.
So it is expected behavior in case of String type variables. The double backslash is escape character (first ) + the actual character (second ).

Jup as I already posted here :wink:

https://forum.uipath.com/t/a-post-in-replace-double-backslashes-with-a-single-slash-wrong-behaviour-requires-staff-attention/164914/4

Hi. This link is not working. Was the page moved?

It is actually a PM with the staff :sweat_smile:

@kwoxer will have to share the content of his post here :slight_smile:

Was a PM with you. There is no more detail about this here in the PM. But is there any update?

I don’t think I have additional explanation, but I will cross-post your link that was in the PM that adds more context:

1 Like