[英]How to load a PDF into memory then read it via acrobat reader?
我想做的是將pdf從閃存驅動器加載到內存中,然后通過acrobat閱讀器閱讀pdf。 這個想法是,如果用戶刪除閃存,他/她仍然可以讀取pdf,因為它已被加載到內存/ RAM中。 我試圖使用從該線程獲取的以下代碼保存和將MemoryStream加載到文件/從文件加載
這用來寫文件
FileStream file = new FileStream("file.bin", FileMode.Create, System.IO.FileAccess.Write);
byte[] bytes = new byte[ms.Length];
ms.Read(bytes, 0, (int)ms.Length);
file.Write(bytes, 0, bytes.Length);
file.Close();
ms.Close();
這用於讀取文件
MemoryStream ms = new MemoryStream();
FileStream file = new FileStream("file.bin", FileMode.Open, FileAccess.Read);
byte[] bytes = new byte[file.Length];
file.Read(bytes, 0, (int)file.Length);
ms.Write(bytes, 0, (int)file.Length);
file.Close();
ms.Close();
我對編程還比較陌生,正在嘗試學習C#。 這似乎是一個愚蠢的問題,但我不明白如何實現代碼。 謝謝您的幫助 :)
將文件下載到某個位置,然后從fileLocation將文件加載到Adobe中。 我不確定您可以直接將內存流傳遞給Adobe Reader。
獲取PDF文件的路徑,然后執行以下操作:
//Get the path
var path = @"C:\Users\MyUser\My Documents\MyPdf.pdf"
//Open adobe reader with the file
Process.Start(path);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.