Site Meter Asp.Net-Csharp,Asp,Ado.Net,Ado,Micosoft,Visualstudio,Visual webgui: Download application or word or doc or pdf code in asp.net,c#

Sunday, November 22, 2009

Download application or word or doc or pdf code in asp.net,c#

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);
}

No comments:

Post a Comment