0

What I am trying to do is load a pdf into memory from a flash drive, then read the pdf via acrobat reader. The idea is that if the user removes the flash he/she can still read the pdf since it was loaded into the memory/RAM. I tried to use the codes below which I got from this thread Save and load MemoryStream to/from a file

This is used to write the file

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

This is used to read the file

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

I am relatively new to programming and I am trying to learn c#. It may seem like a silly question but I can not understand how implement the code. Thanks for the help :)

Community
  • 1
  • 1
Pigeon
  • 117
  • 1
  • 13

1 Answers1

0

Download the file to a location, then load up the file into Adobe from the fileLocation. I am not certain you can pass a memory stream to Adobe Reader directly.

Get the path of the PDF file and do this:

//Get the path
var path = @"C:\Users\MyUser\My Documents\MyPdf.pdf"
//Open adobe reader with the file
Process.Start(path);
Joe Brunscheon
  • 1,949
  • 20
  • 21