C# 是否可以使用WebBrowser对象导航到WPF中的独立存储文件夹
在一个WPF应用程序中,有一个WebBrowser,我希望它使用一个独立的存储文件作为源来导航 如果我通过一条相对路径,它会抱怨。我还使用“msappdata:”和“isostore:”来构建URI,但似乎没有任何效果 我不能使用NavigateToString,因为我需要运行JS文件,而且它们也存储在隔离空间中C# 是否可以使用WebBrowser对象导航到WPF中的独立存储文件夹,c#,wpf,webbrowser-control,isolatedstorage,isolatedstoragefile,C#,Wpf,Webbrowser Control,Isolatedstorage,Isolatedstoragefile,在一个WPF应用程序中,有一个WebBrowser,我希望它使用一个独立的存储文件作为源来导航 如果我通过一条相对路径,它会抱怨。我还使用“msappdata:”和“isostore:”来构建URI,但似乎没有任何效果 我不能使用NavigateToString,因为我需要运行JS文件,而且它们也存储在隔离空间中 有什么想法吗?谢谢 我们最终使用的是这段代码: Uri url = new Uri("file:///" + rootdir + uri.ToString(), UriKind
有什么想法吗?谢谢 我们最终使用的是这段代码:
Uri url = new Uri("file:///" + rootdir + uri.ToString(), UriKind.Absolute);
this.wbControl.Navigate(url);
其中rootdir通过以下方法获得:
public string GetRootDir()
{
Type type = isoStore.GetType();
FieldInfo field = type.GetField("m_RootDir", System.Reflection.BindingFlags.NonPublic | BindingFlags.Instance);
string rootDir = field.GetValue(isoStore).ToString();
return rootDir;
}
但主要问题是,使用file:///不允许使用html5 localstorage对象
还有其他想法吗?使用
标记:如何在我的独立存储中加载index.html文件?我的想法是尝试将index.html
加载为字符串,然后使用NavigateToString
。在index.html
的
部分设置
(前提是您的JS文件位于本地
文件夹中)。我还没试过。谢谢你的回答,但恐怕不行。