Relative path in webBrowser

Viewed 32

I made a form in Visual Studio (Window Forms) and used a webbrowser from the toolbox.

I want to open in the webbrowser a web page from the local drive. In the properties, in the URL box if I write the absolute path (eg c:\xwelcome.html) it works, but how can I use a relative path (eg the page is in my resources folder) ? my path :C:\Users\CCJ\source\repos\myapp\Resources\Welcome\welcome.html I try .\welcome.html but it didn't work. Any idea??

Thanks in advance!

1 Answers

Try it this way

DirectoryInfo dir = new DirectoryInfo(@"C:\Users\CCJ\source\repos\myapp\Resources\Welcome");
        this.webBrowser1.Url = new Uri(String.Format("file:///{0}/welcome.html", dir.FullName));
Related