Download file from server using c#

public void DownloadFile()
{
Response.ContentType="application/ms-word";Response.AddHeader( "content-disposition","attachment; filename=download.doc");
FileStream sourceFile = new FileStream(@"F:downloadexample.doc", FileMode.Open);
long FileSize;
FileSize = sourceFile.Length;byte[] getContent = new byte[(int)FileSize];
sourceFile.Read(getContent, 0, (int)sourceFile.Length);
sourceFile.Close();
Response.BinaryWrite(getContent);
}

Comments

Popular Posts