Have a look please
http://geekswithblogs.net/AzamSharp/archive/2005/09/18/54294.aspx[
^]
I have taken the code from above link and it is working for me.
protected void Button1_Click(object sender, EventArgs e)
{
string path = @"C:\Users\RASHIM\Desktop\isorc2002.pdf";
WebClient client = new WebClient();
Byte[] buffer = client.DownloadData(path);
if (buffer != null)
{
Response.ContentType = "application/pdf";
Response.AddHeader("content-length", buffer.Length.ToString());
Response.BinaryWrite(buffer);
}
}
And if you want to do it in chunk chunk way please follow this
protected void Button1_Click(object sender, EventArgs e)
{
string path = @"C:\Users\RASHIM\Desktop\isorc2002.pdf";
WebClient client = new WebClient();
byte[] bytes = client.DownloadData(path);
Stream oStream = new MemoryStream(bytes);
Response.ContentType = "application/pdf";
byte[] buffer = new byte[1024];
long i = oStream.Length;
while (i >= 0)
{
int readCount = oStream.Read(buffer, 0, 1024);
Response.OutputStream.Write(buffer, 0, readCount);
if (i <= 0)
break;
i = i - 1024;
}
}