Hi
I have an issue while downloading files from a folder.In my application,i have to upload files to a particular folder inside my solution. I dint face any issues while uploading the files to the folder. But while downloading the file from the folder i get an error Access to path 'C:\FolderPath' is denied. I am using windows 7.
Below is the coding for download
protected void radgrdDocumnet_ItemCommand(object sender, GridCommandEventArgs e)
{
if (e.Item is GridDataItem)
{
GridDataItem item = e.Item as GridDataItem;
string id = userProcess.Encrypt(item.OwnerTableView.DataKeyValues[item.ItemIndex]["ID"].ToString());
if (e.CommandName == "download")
{
System.IO.FileStream fs = null;
fs = System.IO.File.Open(Server.MapPath("~/MyFiles"), 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=" + fileName);
Response.ContentType = "application/octet-stream";
Response.BinaryWrite(btFile);
Response.End();
fs = null;
}
}
}