string.Replace不能使用三重正斜杠(///) - 正确的方法?

时间:2016-12-06 23:10:53

标签: c# string replace

我有一个以“file:///”开头的字符串路径,我试图使用string.Replace删除它。这是我的代码:

//This returns a string that starts with "file:///"
string missionPath = missionDataBase.FileLocationLocal; 

missionPath = missionPath.Replace("file///","");

每当我在替换后检查missionPath时,文件:///仍然存在 - 当从字符串中删除正斜杠时,如何正确处理正斜杠?

1 个答案:

答案 0 :(得分:3)

您的搜索字符串中缺少冒号。

missionPath = missionPath.Replace("file:///","");
相关问题