Opening local files in Webkit.NET.

A simple version of WebKitBrowser1.Navigate (localfilehere) for some reason does not work.

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

It sounds ridiculous, but isn't this functionality really present?

+3
source share
7 answers

It looks like you put the wrong URL. You can check it out on

Uri.IsWellFormedUriString 

One reason is that you put a string with national characters.

In this case, the answers do not solve the problem before, because you must also encode the URL.

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

But the easiest way to get the correct url is

 string url = new Uri(pathToFile, UriKind.Absolute).AbsoluteUri; 
+5
source share

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

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

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

+3
source share

The WebKit.Net 0.5 Navigate() function takes a string as its parameter (local / web files). For a local file, for example: c:\xxx\yyy zzz.htm , you can pass the move function as follows: -

 dim sFile As String = "c:\xxx\yyy zzz.htm" Dim url as new Uri(sFile, UriKind.Absolute) 'Now pass the file required formatted absolute path WebKitBrowser1.Navigate(url.AbsoluteUri) 
+2
source share

I found a solution to your problem:

1.) Make sure the path starts with "file: ///"
2.) Make sure you are using the full file path
3.) Make sure all backslashes are changed to slashes

4.) Make sure you replace all spaces, ","% 20 "
5.) Make sure the file ends with ".html"

So the file is here:
"C: \ Program Files \ test.html"
should become:
"File: /// C: /Program%20Files/test.html"

Hope this helps.

+1
source share

Create a sample HTML page. Download my resources.

Use this code: WebKitBrowser1.document.write (my.resources.page.html)

+1
source share

Suppose index.html is in the bin / debug folder, and then

Use "file: ///" + Environment.CurrentDirectory.Replace (@ "\", @ "/") + "/index.html"

Suppose index.html is in bin / debug and created a folder like www then

Use "file: ///" + Environment.CurrentDirectory.Replace (@ "\", @ "/") + "/www/index.html"

+1
source share

In Google Chrome, you can open a local file by entering the file: ///, and then the full path to the file, so you may need to use the same operator in Webkit.

0
source share

All Articles