Harish Batchu

Harish Batchu

  • NA
  • 255
  • 70.3k

The Files Exist or not in directroy?

Nov 26 2018 10:12 PM
I am checking the file exist in a folder but i am getting every time false. In that folder i have file.
 
code
-------
string filename = ((Label)e.Item.FindControl("Label2")).Text;
string filePath = @"Uploads\Master\MyDocsFiles\" + filename;
bool fileavail = File.Exists(filePath) ? true : false;
if (fileavail) {
Response.AddHeader("Content-Disposition", "attachment;filename=\"" + filePath + "\"");
Response.TransmitFile(Server.MapPath(filePath));
Response.End();
}
else
{
fileexist.Visible = true;
}
That is the code. Please give me the solution 
 

Answers (4)