Hi @ rkumar9090,
This error will be raised if file is not present there.You need to check whether file is prsented.
If file is not prsent there so error will be thrown.
To avoid this erro you need to handle as i say below.
protected void Download(object sender, EventArgs e)
{
string filePath = (sender as LinkButton).Text;
if (File.Exists(filePath))
{
string fileName = Path.GetFileName(filePath);
Response.Clear();
Response.Buffer = true;
Response.AddHeader("content-disposition", "attachment;filename=" + fileName);
Response.Charset = "";
Response.ContentType = "application/vnd.ms-word ";
Response.WriteFile(filePath);
Response.Flush();
Response.End();
}
else
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script type='text/javascript'>alert('file is not present');</script>");
}
}
I hope it will solve all your problem