0

When doing remote debugging. I share the directory say "d:\debug\app" on my remote debug machine to host machine.

On my host machine I setup the debug setting to use remote machine: "user@machine" and start external program "\\machine\debug\app\start.exe"

When following program runs:

        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"

getting error:

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

Looks like the Directory.SetCurrentDirectory() is taking the shared folder as root. and trying to do "\machine\debug" + "debug\app"

How to fix this?

It's not a problem of formate. There is a similar question here: How do I convert a UNC path back to an absolute local path on the remote PC?

But, the author give a self code solution. I would like something easy with existing API and tools.

Community
  • 1
  • 1
user1947415
  • 933
  • 4
  • 14
  • 31
  • That uri doesn't help us help you, it is malformed. Use the Location property instead. – Hans Passant Aug 30 '16 at 01:10
  • @HansPassant, It's not the problem of the formate. The location is still "\\\\machine\debug\app\lib.dll" However, I need something to return "app\lib.dll". Or I need to know the share folder "d:\debug\app" – user1947415 Aug 30 '16 at 16:56
  • Now you have too many backslashes before the share name. Are you mis-typing this or is it real? Mapping a drive letter to the share would be wise to get ahead I guess. – Hans Passant Aug 30 '16 at 17:15
  • @HansPassant, it's escap showing in debug window. As I said, it's not the formate. you can ignore all format issue in my post. – user1947415 Aug 30 '16 at 17:20
  • Yes, the problem is how do I map the local driver to share path. Like the other question have: "\\PC2\SharedFolder\Foo\Bar.exe", which points to "C:\SomeFolder\Foo\Bar.exe". How do I map "\\PC2\SharedFolder\" to "C:\SomeFolder\". Is there a build in C# tool to return the shared folder path. – user1947415 Aug 30 '16 at 17:39

0 Answers0