将双斜杠替换为单斜杠 c# winform

Replace Double slash to single slash c# winform

请问如何在C# Winforms 中将双斜杠替换为单斜杠。我目前正在使用 vb.net 2010 Ultimate 和 SQL Server 2008。

我正在从我的 SQL 服务器检索我的 Crystal 报告路径,但它把 \ 变成了 \\

我尝试使用

string.replace(@"\\", @"\") 

但它仍然 returns \\ 在我的道路上。

请帮忙

我的密码是

string path = Getvalue.Path.Replace(@"\", @"\");
myReportDocument.Load("@"+path);

存储在SQL服务器中的路径

\server\crystal\codes\Report\Summary_of_applicant.rpt

返回数据

\careersql\MIS\codes\Report\Summary_of_applicant.rpt

用另一个字符串替换任何字符串很容易,但是 \ 是必须转义的特殊字符。

string path = Getvalue.Path.Replace("\\","\"); 

虽然我会使用 Path.Combine 来构建路径。

string reportFile = "Summary_of_applicant.rpt"; // or more complex path
string path = Path.Combine(GetValue.Path,reportFile);

大家下午好,谢谢大家的评论和帮助。 我的问题的答案是错误的编码路径和数据库中的代码。

错误数据=@"\careersql\MIS\codes\Report\Summary_of_applicant.rpt"

正确数据=\sever\crystal\codes\Report\Summary_of_applicant.rpt