0

I am running my C# dev environment in a Win10 VM running under Parallels on OSX. It works well. However...

I have a form, and the form has a webBrowser control. And the webBrowser control wants to load an HTML page which is a local file, stored relative to the executable. But:

  • if I set the Url property of the browser control to file:///./web/mapping.html then I get a "cannot find file" error. And yes, I've checked that the file is in the project bin\Debug\web folder.
  • If I try doing it in code and using the Application.Startup parameter instead, so:

    this.mapWindow.Navigate(new Uri(Application.StartupPath + "\\web\\mapping.html"));
    

    (where mapWindow is the name of my browser control) then I get a UNC returned such as

    file://mac/home/Documents/Visual Studio 2015/Projects/WindowsFormsApplication1/WindowsFormsApplication1/bin/Debug/web/mapping.html
    

    and the browser is blank.

Parallels gives me a handy shortcut to //mac/home mapped onto the Z:\ drive, and if I use that (as an explicit path) then it works correctly. So my problem is getting the UNC as a local path. I've tried

Convert UNC path to local path in C#

but that seems to want a remote server ("mac" in this case) which it can't find, so I can't make that work either.

So should I give up, force it to be a direct path and only worry about it when I come to the final build, because it will be installed on a Windows box, or is there something that I can do?

I'm loathe to waste too much time solving something which might only affect my dev environment, but it does mean that I am building and testing something that I have to change, and hope it works, before the final build.

Community
  • 1
  • 1
StuartR143
  • 369
  • 2
  • 10

1 Answers1

0

Hah! Almost as soon as I had finished writing I stumbled across the answer by mistake.

If you set Url to something at design time - something that you know will be there all the time like www.google.com, then the Navigate() function works perfectly across the VM with the UNC.

Bizarre! But solved :)

StuartR143
  • 369
  • 2
  • 10