Crystal reports 打开crystal report export to stream函数中的文件

Crystal reports 打开crystal report export to stream函数中的文件,crystal-reports,Crystal Reports,如何从通过crystal report export to stream功能导出的流中直接打开文件?我正在使用vs2010和sap crystal report MemoryStream m = (MemoryStream)(PReport.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat)); FileStream f = new FileStream(purchaseCombo.Selected

如何从通过crystal report export to stream功能导出的流中直接打开文件?我正在使用vs2010和sap crystal report

MemoryStream m = (MemoryStream)(PReport.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat));
FileStream f = new FileStream(purchaseCombo.SelectedItem.ToString(),FileMode.Create,System.IO.FileAccess.Write);
byte[] bytes = new byte[m.Length];
m.Read(bytes, 0, (int)m.Length);
f.Write(bytes, 0, bytes.Length);
f.Close();
m.Close();

这取决于要导出的文件。由于Crystal Reports可以导出许多不同的文件类型,并且每个文件类型都有一个特定的程序来处理,因此您需要搜索您感兴趣的确切文件类型。例如,通过在internet上进行快速搜索,我发现可以使用该方法在WebBrowser组件(在WPF应用程序中)内直接预览html文件流。也许有一些第三方组件公开了直接从内存打开文件的方法

不过,最简单的方法是使用该方法将临时文件导出到磁盘而不是内存,并在使用后将其删除,因为许多组件从路径而不是内存读取。导出文件之前,可以使用创建临时文件并对其命名的方法