Nikhil Rajan
Nikhil Rajan

Reputation: 33

Save byte[] stream as PDF file asp.net

i have a byte[] stream of data. i need to save this byte in to pdf format in disk. can any one help

Thanks in advance

Upvotes: 3

Views: 34020

Answers (2)

LukeH
LukeH

Reputation: 269318

You could use File.WriteAllBytes:

byte[] yourByteArray = GetYourByteArrayFromSomewhere();
File.WriteAllBytes(@"c:\example.pdf", yourByteArray);

Upvotes: 8

George Johnston
George Johnston

Reputation: 32258

One option is to create a FileStream object and write the bytes to it with your PDF name and extension. e.g.

byte[] bytes = SomeMethodToGetBytesThatYouDefine();
FileStream fs = new FileStream(@"c:\somepath.pdf",FileMode.OpenOrCreate);
fs.Write(bytes,0,bytes.Length);
fs.Close();

Upvotes: 9

Related Questions