Q:

Remove escape from string c#

I have a path in my network who I can use in File Explorer without problems:
\\MyNetwork\Projects\16000

Now I want to access it using Directory.Exists as:
var normalFolderPath = @"\MyNetwork";
var number = @"\16000"

var a = Directory.Exists($@"{normalFolderPath}\{number}");

But this: $@"{normalFolderPath}\{number}" return \\MyNetwork\\16000 but if I try to access it that on File Explorer just can not found, but if I remove \ from subfolder like: \\MyNetwork\16000 it works!, how can I remove one \ from string in c#

A:

You're complaining that your string has two slashes in the middle of it, but you put two slashes in the middle of it:

number is the literal string \16000
You asked c# to concatenate normalfolderpath with number, separated by slash: {normalFolderPath}\{number}

Naturally, you'll end up with two slashes; one from number, and one as the separator. To demo what I mean, here is an altered code:
var normalFolderPath = @"\MyNetwork";
var number = @"!16000"

var a = Directory.Exists($@"{normalFolderPath}={number}");

This will produce the string \MyNetwork=!16000: the = is the separator between the interpolated fields and ! came from the start of number

But this: $@"{normalFolderPath}\{number}" return \\MyNetwork\\16000

I disagree: it will definitely return \MyNetwork\\16000 with only one slash at the start and two in the middle. No way will that code you put, return something with two slashes at the start

As has been commented, you should use Path.Combine to combine path elements:
var normalFolderPath = @"\\MyNetwork";
var number = "16000"

var a = Directory.Exists(Path.Combine(normalFolderPath,number));

