I am saving my files in the folder in my web form project /Upload/Secret/ and its saved correct. and i save the file name in database. I am try to view the files which is pdf and i created new item to my project .dbml and i drag and drop my table on that item. Now when i press the link button to view my file this error appeared : Could not find a part of the path.
I got this code from youtube https://www.youtube.com/watch?v=h7sswv6LyIw
protected void linkfilebtn_Click1(object sender, EventArgs e)
{
int Rowindex = ((GridViewRow)((sender as Control)).NamingContainer).RowIndex;
string filelocation = DGDEPT.Rows[Rowindex].Cells[3].Text;
string filepath = Server.MapPath("~/Upload/Secret/" + filelocation);
WebClient user = new WebClient();
Byte[] filebuffer = user.DownloadData(filepath);
if (filebuffer != null)
{
Response.ContentType = ("application/pdf");
Response.AddHeader("content-length", filebuffer.Length.ToString());
Response.BinaryWrite(filebuffer);
}
}
the expected result view the pdf file but the actual it shows me error in this line
Byte[] filebuffer = user.DownloadData(filepath);
where is the error ?