我想,以取代"\\"与"\"(两到只有一个).我正在使用:
string myPath = Path.GetFullPath(fileName);
string correctPath = myPath.Replace(@"\\", @"\");
Run Code Online (Sandbox Code Playgroud)
但没有任何反应,correctPath中的字符串继续 "\\"
DGi*_*bbs 10
您可能在调试器中暂停时查看字符串.将值打印到控制台窗口,没关系.
string myPath = @"hello\\world";
string correctPath = myPath.Replace(@"\\", @"\");
Console.Write(correctPath);
Console.Read();
Run Code Online (Sandbox Code Playgroud)