private void SaveQuotePrint() { ObjectParameter tranDT = new ObjectParameter("TranDT", typeof(DateTime?)); ObjectParameter result = new ObjectParameter("Result", typeof(Int32?)); var openFileDialog = new OpenFileDialog(); if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (openFileDialog.FileName.Length > 0) { string filePath = openFileDialog.FileName; string fileName = openFileDialog.SafeFileName; // Read the file (as one string) and convert it to Byte Array byte[] fileContents = System.IO.File.ReadAllBytes(filePath); string attachmentCategory = "QuotePrint"; try { _context.usp_QT_FileManagement_Save(QuoteNumber, attachmentCategory, fileName, fileContents, tranDT, result); lnkGetQuotePrint.Enabled = lnkDeleteQuotePrint.Enabled = true; lblQuotePrint.Text = fileName; PrintSaved = true; } catch (Exception ex) { string err = (ex.InnerException != null) ? ex.InnerException.Message : ex.Message; MessageBox.Show(err, "Error at SaveQuotePrint()"); } } } }