我正在处理版本历史对话框,并创建了一个示例来测试它。但是,该示例似乎找不到 HTML 文件:
var dlg = new VersionHistoryDialog();
var uri = new Uri(@"pack://application:,,,/VersionHistory.html", UriKind.Absolute);
var source = Application.GetResourceStream(uri).Stream; // This line throws the error
dlg.Stream = source;
var result = dlg.ShowDialog();
label1.Content = result;
上面代码中的那一行引发了这个错误:
System.IO.IOException was unhandled
Message=Cannot locate resource 'versionhistory.html'.
Source=PresentationFramework
StackTrace:
at MS.Internal.AppModel.ResourcePart.GetStreamCore(FileMode mode, FileAccess access)
at System.IO.Packaging.PackagePart.GetStream(FileMode mode, FileAccess access)
at System.IO.Packaging.PackagePart.GetStream()
at System.Windows.Application.GetResourceStream(Uri uriResource)
....
所以....我该怎么办?该文件名为“ ”,并且它与请求它VersionHistory.html
的文件位于同一文件夹(“视图”)中。xaml.cs