Download application or word or doc or pdf code in asp.net,c#
if (Page.IsPostBack){
Response.ContentType="application/ms-word";
Response.AddHeader( "content-disposition","attachment; filename=RegistrationFormDownload.pdf");
//Source from server
FileStream sourceFile = new FileStream(@"c:\inetpub\vhosts\www.com\httpdocs\Form.pdf", System.IO.FileMode.Open,System.IO.FileAccess.Read, System.IO.FileShare.Read );
//Source from Local system
FileStream sourceFile = new FileStream(@"system file path", System.IO.FileMode.Open,System.IO.FileAccess.Read, System.IO.FileShare.Read );
long FileSize;
FileSize = sourceFile.Length;
byte[] getContent = new byte[(int)FileSize];
sourceFile.Read(getContent, 0, (int)sourceFile.Length);
sourceFile.Close();
Response.BinaryWrite(getContent);
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment