string DownloadDirectoryPath = @"C:\\Program Files\\companyname\\productname\\username\\0\\2012081617085746"
Run Code Online (Sandbox Code Playgroud)
(这是我从sql server获得的路径)但我的应用程序使用单斜杠,所以我尝试使用
DownloadDirectoryPath= DownloadDirectoryPath.Replace(@"\\", @"\");
Run Code Online (Sandbox Code Playgroud)
但这不起作用,我得到相同的字符串.任何建议?
请注意:
以上值是我在观察窗口看到的
你没有在DownloadDirectoryPath的值前面得到@,所以它实际上并没有得到任何\,而只有\'s
执行console.WriteLine(DownloadDirectoryPath)来检查它中的实际内容.
编辑(OP更新的问题):
如果在调试时将鼠标悬停在包含它的变量(或使用监视窗口)上,则VS将显示单个\ as \\以从转义字符中消除歧义.将它写入控制台,文件或其他输出以检查它到底是什么.
| 归档时间: |
|
| 查看次数: |
111 次 |
| 最近记录: |