开发者

opening pdf file in console app

开发者 https://www.devze.com 2023-01-21 00:38 出处:网络
Is there a way to have my con开发者_JAVA技巧sole app open my PDF file (in my default application for PDFs) given a byte array?If you want to open the PDF in the default application you will have to sa

Is there a way to have my con开发者_JAVA技巧sole app open my PDF file (in my default application for PDFs) given a byte array?


If you want to open the PDF in the default application you will have to save it first to a temporary location:

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);
0

精彩评论

暂无评论...
验证码 换一张
取 消