在运行时将//替换为/ [英] Replace // with / at run time
本文介绍了在运行时将//替换为/的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在//我想要单/的路径中.每当我调试它时,我都会在运行时获取//.我也用过替换方法.但它不起作用.我的代码是
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(@"\\", @"\");
推荐答案
仅在调试模式下会得到 \\
,因为在可视化字符串文字时,调试器会为该字符串重新转义.可视化的目的,但是,当使用它进行操作时,字符串文字将只包含一个 \
.
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 \
.
这篇关于在运行时将//替换为/的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文