private void btnLoadFrom_Click(object sender, EventArgs e)
{
OpenFileDialog dlg = new OpenFileDialog();
DialogResult res = dlg.ShowDialog(this);
if (res == DialogResult.Cancel)
{
return;
}
string fpath = dlg.FileName;
FileInfo fi = new FileInfo(fpath);
if (fi.Length > MAX_BLOB_FILESIZE_MB * 1000 * 1024)
{
res = MessageBox.Show(this,
"SQLite does not handle BLOBs larger than " + MAX_BLOB_FILESIZE_MB + "MB very well.\r\n" +
"It is highly recommended that you don't add such large BLOB\r\n" +
"fields into the database due to performance reasons.\r\n" +
"Do you want to abort the operation?",
"Warning",
MessageBoxButtons.YesNo,
MessageBoxIcon.Warning);
if (res == DialogResult.Yes)
{
return;
}
}
if (_blobProvider != null)
{
Be.Windows.Forms.DynamicFileByteProvider dp = _blobProvider as Be.Windows.Forms.DynamicFileByteProvider;
if (dp != null)
{
dp.Dispose();
}
}
try
{
// Copy the file to the temporary BLOB file
if (File.Exists(Configuration.TempBlobFilePath))
{
File.Delete(Configuration.TempBlobFilePath);
}
File.Copy(fpath, Configuration.TempBlobFilePath);
}
catch (Exception ex)
{
MessageBox.Show(this, ex.Message, "Internal Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
} // catch
_blobProvider = new DynamicFileByteProvider(Configuration.TempBlobFilePath);
ucHexEditor.ByteProvider = _blobProvider;
lblBlobSize.Text = "Blob contains " + Utils.FormatMemSize(fi.Length, MemFormat.KB);
}