mahe21.tir
July 15th, 2009, 10:13 AM
Hi,
I have a button which needs to download the file, simaltaneously it has to enable or disable the linkbutton on a click event. I went for the following code which never works for me.. The problem is there in writing the file in response. Any idea is highly valuable.
Thanks in advance..
Given the code below..
----
LinkButton1.Enabled = false;
System.IO.FileStream fs = null;
fs = System.IO.File.Open("c://4377.doc", System.IO.FileMode.Open);
byte[] btFile = new byte[fs.Length];
fs.Read(btFile, 0, Convert.ToInt32(fs.Length));
fs.Close();
Response.AddHeader("Content-disposition", "attachment; filename=4377.mpp");
Response.ContentType = "application/octet-stream";
Response.BinaryWrite(btFile);
Response.End();
-----------
Thanks
Maheshkumar
I have a button which needs to download the file, simaltaneously it has to enable or disable the linkbutton on a click event. I went for the following code which never works for me.. The problem is there in writing the file in response. Any idea is highly valuable.
Thanks in advance..
Given the code below..
----
LinkButton1.Enabled = false;
System.IO.FileStream fs = null;
fs = System.IO.File.Open("c://4377.doc", System.IO.FileMode.Open);
byte[] btFile = new byte[fs.Length];
fs.Read(btFile, 0, Convert.ToInt32(fs.Length));
fs.Close();
Response.AddHeader("Content-disposition", "attachment; filename=4377.mpp");
Response.ContentType = "application/octet-stream";
Response.BinaryWrite(btFile);
Response.End();
-----------
Thanks
Maheshkumar