c#如何使用replace函数将"\"替换成"\\"

时间:2025-03-17 12:05:01

当我使用
 String str="c:\aa.xls";
 str=str.Replace("\","\\");时,括号为红色错误的,那么如何才能替换成"\\"呢,双引号里的内容

解决的方法:

1.String str=@"c:\aa.xls";
str = str.Replace(@"\", @"\\");

2.string i = @"c:\aa.xls";

Response.Write(i.Replace("\\","\\\\"));

相关文章