次の方法で Web ブラウザを開こうとしています。ただし、ブラウザが url / ファイル パスを開くと、フラグメント部分が (「#anchorName」から「%23anchorName」に) 壊れてしまい、処理されていないように見えます。基本的に、ファイルは開きますが、ドキュメント内の適切な場所にジャンプしません。ファイルを開いてフラグメントを処理する方法を知っている人はいますか? これに関するヘルプは大歓迎です。
開くパスの例は、「c:\MyFile.Html#middle」です。
// calls out to the registry to get the default browser
private static string GetDefaultBrowserPath()
{
string key = @"HTTP\shell\open\command";
using(RegistryKey registrykey = Registry.ClassesRoot.OpenSubKey(key, false))
{
return ((string)registrykey.GetValue(null, null)).Split('"')[1];
}
}
// creates a process and passes the url as an argument to the process
private static void Navigate(string url)
{
Process p = new Process();
p.StartInfo.FileName = GetDefaultBrowserPath();
p.StartInfo.Arguments = url;
p.Start();
}