0

我想替换"\\""\"(二比一)。我在用着:

string myPath = Path.GetFullPath(fileName);    
string correctPath = myPath.Replace(@"\\", @"\");

但是什么也没发生,正确路径中的字符串继续"\\"

4

1 回答 1

10

您可能正在调试器中暂停时查看字符串。将值打印到控制台窗口,这很好。

string myPath = @"hello\\world";
string correctPath = myPath.Replace(@"\\", @"\");
Console.Write(correctPath);
Console.Read();
于 2013-05-13T16:07:19.560 回答