Hi nagaraju60,
Use try catch and check.
string fileName = "Test.doc";
string filePath = Server.MapPath("~/uploads/" + fileName);
string contentType = "application/vnd.ms-word";
if (System.IO.File.Exists(filePath))
{
Response.Clear();
Response.ContentType = contentType;
Response.AddHeader("content-disposition", "attachment;filename=" + fileName);
Response.Charset = "";
try
{
Response.WriteFile(filePath);
Response.Flush();
System.IO.File.Delete(filePath);
}
catch (Exception ex)
{
Response.Write(ex.Message);
throw;
}
finally
{
Response.End();
}
}
else
{
Response.Write("File not exist.");
}
Screenshot