Directory.SetCurrentDirectory()在远程调试时搞砸了

时间:2016-08-29 23:38:10

标签: c# debugging directory remote-debugging

进行远程调试时。我分享目录说" d:\ debug \ app"在我的远程调试机器上托管机器。

在我的主机上,我设置了调试设置以使用远程机器:" user @ machine" 并启动外部程序" \\ machine \ debug \ app \ start.exe"

以下程序运行时:

        string codeBase = Assembly.GetExecutingAssembly().CodeBase;//codeBase="file://machine/debug/app/lib.dll"
        UriBuilder uri = new UriBuilder(codeBase);
        string path = Uri.UnescapeDataString(uri.Path);
        Directory.SetCurrentDirectory(Path.GetDirectoryName(path));//Path.GetDirectoryName(path)="\\debug\\app"

收到错误:

System.IO.DirectoryNotFoundException was unhandled
  Message="Could not find a part of the path '\\\\machine\\debug\\debug\\app'."

看起来Directory.SetCurrentDirectory()以root身份获取共享文件夹。并尝试做" \ machine \ debug" +" debug \ app"

如何解决这个问题?

这不是甲酸盐的问题。 这里有一个类似的问题:How do I convert a UNC path back to an absolute local path on the remote PC?

但是,作者给出了一个自我代码解决方案。我想用现有的API和工具轻松一些。

0 个答案:

没有答案