When using a break point the root string contains the path with double backslash when I copy this complete path and try to get to it in the File Explorer the path can't be found. But if manual I remove one backslash from each part of the path so the whole path will be with one backslash instead two then it will find the path in the File Explorer. This is the problem in the code. I'm getting exception that the path can't be found but only because the path string is built for some reason with double back slash :
Then it's getting to a catch and there when I'm clicking on the small Message small magnifying glass I see the same root string but with one backslash. So I'm confuse why first in the break point it's with two backslash and in the catch with one backslash ? And how can I fix it so it will find the path with double backslash or with one only ?
I tried to add in the code this line :
Path.GetFullPath(root).Replace(@"", @"");
but it didn't change anything. Still, in the break point it's with two backslashes.
And most of the root paths are fine, but at some points, it's getting to the path in the screenshots and it's not finding this path because it's with two backslashes, but the path does exist and other paths are fine, so I can't figure out why this specific path can't be with two backslashes?
What should I do in this case/s ?
I also saw in some answers and solutions that doing this replace Replace(@"", @"");
is not so good because some path's might be in the format E:\test est1 est2
, which is a mix of two and one backslash.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…