how to save a pdf in a folder after creation

Posted by Klbaiju under ASP.NET on 9/6/2012 | Points: 10 | Views : 3020 | Status : [Member] | Replies : 3
Hi,

following is the code for creating a pdf file from bytes. it is working fine.

but i want to save the pdf file in a folder.

how it is possible.



SqlDataAdapter da = new SqlDataAdapter("select * from downloads where id=93 ", con);
DataSet ds = new DataSet();
da.Fill(ds);
string pdfName = ds.Tables[0].Rows[0]["filename"].ToString();

Byte[] bytes = (Byte[])ds.Tables[0].Rows[0]["downloads"];
Response.Buffer = true;
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = ds.Tables[0].Rows[0]["filename"].ToString();
Response.AddHeader("Content-Disposition", "attachment;filename=" + ds.Tables[0].Rows[0]["filename"].ToString());
Response.BinaryWrite(bytes);
Response.Flush();
Response.End();



regards

Baiju




Responses

Posted by: Vikash on: 9/17/2012 [Member] Starter | Points: 25

Up
0
Down
hi klbaiju use this.........

string path=@"~\Docs\"+filenamewithxtnsion; //unicode here.

just use File.SaveAs("path") option.

found interesting mark as answer.......

Regards,
Vikash Pathak

Klbaiju, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hariinakoti on: 9/17/2012 [Member] Starter | Points: 25

Up
0
Down
is it working like this vikash?

Thanks & Regards
Hari

Klbaiju, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vikash on: 9/17/2012 [Member] Starter | Points: 25

Up
0
Down
Please use this code if not working then i will see it back tomorrow............

byte[] myData = byte[myByteStream.Length];

myByteStream.Read(myData, 0, myByteStream.Length);

System.IO.File.WriteAllBytes("c:\myfile.pdf", myData);



Regards,
Vikash Pathak

Klbaiju, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response