How to open a file directly from a MemoryStream opposed to writing to disk(pdf file)

Posted by Kunal09 under C# on 10/12/2011 | Points: 10 | Views : 26476 | Status : [Member] | Replies : 0

I am doing code in C#, and i have created pdf using itextsharp,
now i want to open my pdf directly in Acrobat Reader 9 (without giving any path to filestream)and then ask to client , wheather he want to save that pdf file.

MemoryStream ms = new MemoryStream();
PdfWriter writer = PdfWriter.GetInstance(pDoc, ms);

var file = System.IO.Path.GetTempFileName();
using (var fileStream = File.OpenWrite(file))
var buffer = ms.GetBuffer();
fileStream.Write(buffer, 0, (int)buffer.Length);
I have used above code, but getting error SecurityException was unhandled by user code -- File operation not permitted. Access to path '' is denied

when i have used below code den pdf is getting created , means Admin settings have not any problems.

writer = PdfWriter.GetInstance(doc, new FileStream(filpath, FileMode.Create));
so plz help me , so that i will open direct pdf from memorystream without saving it in a disk.



(No response found.)

Login to post response