[英]How do you open a local html file in a web browser when the path contains an url fragment
[英]How to open a local html file using NavigationWindow when path contains URL fragment?
我正在使用NavigationWindow顯示html文件,在路徑不包含任何#或非法字符之前,它工作正常。
我只想知道當路徑包含URL片段時是否可以打開html文件,例如:如下所示的錨點。
"c:\MyFile.Html#tips"
目前我收到以下異常...
Could not find file 'c:\MyFile.Html#tips'
System.Net.WebException was unhandled
HResult=-2146233079
問題在於URI的創建,URI類似乎存在一些錯誤。
以下內容生成的URI不同,
var filePath = @"c:\MyFile.Html#tips";
var uri = new Uri(filePath);
var uri2 = new Uri("file://" + filePath);
uri
片段部分為空,但uri2
片段部分正確為“ #tips”。
即使在將URI創建為uri2
之后,查詢仍存在相同類型的問題,在此處可以找到報告的查詢字符串錯誤, 為什么System.Uri無法識別本地文件路徑的查詢參數? 而且Uri類不會使用查詢字符串來解析文件系統URL
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.