I have a C# application that is uploading files to a sql server, I use this code to get the pdf file and then I change it to "bytes" for upload on the SQL Server database.
private void mButtonAddCV_Click(object sender, EventArgs e)
{
openFileDialog1.Filter = "PDF Files | *.pdf";
if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
if (openFileDialog1.FileName.Length > 0)
{
pathCV = openFileDialog1.FileName;
}
}
// Read the file and convert it to Byte Array
string filePath = pathCV;
string contenttype = String.Empty;
contenttype = "application/pdf";
if (contenttype != String.Empty)
{
Stream fs = File.OpenRead(filePath);
BinaryReader br = new BinaryReader(fs);
bytes = br.ReadBytes((Int32)fs.Length);
}
}
I use the code below to upload the file:
if (!mConnector.Update("INSERT INTO **** (***, ***, CV) " +
"VALUES ('" + *** + "', '" + *** + "', '" + bytes + "')"))
{
Messages.errorMessageBox("This CV already exists.");
}
else
{
ChangeScreen(ActiveScreen, ActiveScreens.ActiveScreen_CVList);
}
But now I don't know how to download this file and how to make a pdf file with the data stored on the database to see it. Can anyone help me?
Thanks!