在控制台应用中打开pdf文件

时间:2010-10-21 17:25:34

标签: c#

有没有办法让我的控制台应用程序在给定字节数组的情况下打开我的PDF文件(在我的PDF默认应用程序中)?

1 个答案:

答案 0 :(得分:10)

如果要在默认应用程序中打开PDF,则必须先将其保存到临时位置:

byte[] buffer = GetPdfData();

// save to temp file
string path = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()+".pdf");
File.WriteAllBytes(path, buffer);

// open in default PDF application
Process process = Process.Start(path);
process.WaitForExit();

// clean up temp file
File.Delete(path);
相关问题