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 :)