Opening local files in Webkit .NET

前端 未结 7 1958
天涯浪人
天涯浪人 2021-01-20 11:33

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

7条回答
  •  说谎
    说谎 (楼主)
    2021-01-20 12:04

    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;
    

提交回复
热议问题