How to convert
\"String path = @\"C:\\Abc\\Omg\\Why\\Me\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\";
into
String path = @\"C:\\A
var path = @"C:\Abc\Omg\Why\Me\\\\\\\\\\\\\\\\\\\\\";
path = path.TrimEnd('\\') + '\\';
another solution is
var path = @"C:\Abc\Omg\Why\Me\\\\\\\\\\\\\\\\\\\\\";
path = Path.GetFullPath(path);
You can just construct path using the Path
static class:
string path = Path.GetFullPath(@"C:\Abc\Omg\Why\Me\\\\\\\\\\\\\\\\\\\\\");
After this operation, variable path
will contain the minimal version:
C:\Abc\Omg\Why\Me\
You can use path.TrimEnd('\\')
. Have a look at the documentation for String.TrimEnd.
If you want the trailing slash, you can add it back easily.