Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想替换"\\"为"\"(二比一)。我在用着:
"\\"
"\"
string myPath = Path.GetFullPath(fileName); string correctPath = myPath.Replace(@"\\", @"\");
但是什么也没发生,正确路径中的字符串继续"\\"
您可能正在调试器中暂停时查看字符串。将值打印到控制台窗口,这很好。
string myPath = @"hello\\world"; string correctPath = myPath.Replace(@"\\", @"\"); Console.Write(correctPath); Console.Read();