将pdf存储为tmp并将web浏览器指向它



我有点困惑,我如何把我的网页浏览器指向一个临时的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一起工作!

尝试:

b.Navigate("file://" + temporaryFileName);

最新更新