I want to create a document matrix that allows users to upload files into a web based database. I am getting errors regrading to the access the file path. System.IO.FileNotFoundException: 'Could not find file 'C:\Program Files (x86)\IIS Express\auto.docx'.'
The data type in the database is Varbinary(MAX). Also there is no issue with the connection to the database.
Here is the button event for uploading the file.
protected void Button1_Click(object sender, EventArgs e)
{
//get file path from file upload button
String filepath= System.IO.Path.GetFullPath(FileUpload1.PostedFile.FileName);
//Converts file(.txt pdf etc..) into byte[]
byte[] filedata = System.IO.File.ReadAllBytes(filepath);
//Insert file into database
cmd.CommandText = "INSERT INTO tbl_test (Name)" +
" Values ('" + TextBox1.Text + "','" + filedata + "')";
cmd.Connection = mycon;
cmd.ExecuteNonQuery();
mycon.Close();
}