Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Opening local files in Webkit .NET

A simple WebKitBrowser1.Navigate(localfilehere) doesn't work for some reason.

I tried adding "file://" to the URL but that didn't work either.

This seems ridiculous but is this functionality really not present?

like image 497
Shawn Avatar asked Nov 25 '25 06:11

Shawn


2 Answers

Its look like you put wrong url. You can check it by

Uri.IsWellFormedUriString

One of the reasons - you put the string with national symbols.

In this case the answers before do not resolve you problem, because you also should encode url.

You can use System.Web.HttpUtility.UrlEncode for it and then apply a solution described before by X Enterprises (but you should not replace spaces - it would be already done by encoding) .

But the easiest way to get correct url is

string url = new Uri(pathToFile, UriKind.Absolute).AbsoluteUri;
like image 192
Kamil Gareev Avatar answered Nov 27 '25 20:11

Kamil Gareev


"file://" is the correct protocol. To get to a file say in... "c:\temp\test.html" you can try something like:

"file://c/temp/test.html"

Note the forward slash and the absence of the colon after the drive letter.

like image 35
Perishable Dave Avatar answered Nov 27 '25 19:11

Perishable Dave



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!