0

对于如何将网络浏览器指向临时 PDF 文件,我有点困惑。如果将其指向 PDF,我会收到一个下载框对话框,要求我下载文件和无效的浏览器页面。

WebBrowser b = new WebBrowser();
DocumentContainer.Child = b;
temporaryFileName = System.IO.Path.GetTempFileName();
System.IO.File.WriteAllBytes(temporaryFileName, this.CurrentDocument.DocumentData); //pdf
b.Navigate(temporaryFileName);

我还尝试将我的文件写入 Environment.SpecialFolder.ApplicationData 以备不时之需,并且遇到错误

"file does not begin with '%pdf'"

WebBrowser b = new WebBrowser();
DocumentContainer.Child = b;
temporaryFileName = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + this.CurrentDocument.Title+".pdf";
System.IO.File.Create(temporaryFileName);//pdf
b.Navigate(temporaryFileName);

我已经用其他文件做了几次,但由于某种原因它不想使用 pdf!

4

1 回答 1

0

尝试:

b.Navigate("file://" + temporaryFileName);
于 2013-05-09T21:00:25.513 回答