Replace // with / at run time [duplicate]

混江龙づ霸主 提交于 2019-12-13 03:59:41

问题


i'm getting // in path i want single /. whenever i'm debugging it i'm getting // at run time. i have also used replace method. but it isn't working. My code is

 string inputFile = 
 Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName + 
 "\\InputFiles\\" + config.country + ".txt";
  inputFile = inputFile.Replace(@"\\", @"\");

回答1:


You're getting \\ only in debug mode, because when visualizing the string literal the debugger is re-escaping it for the visualization purposes, however when operating with it, the string literal will contain only a single \.



来源:https://stackoverflow.com/questions/50942390/replace-with-at-run-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!