string ImagePath = Path.GetFullPath(openImage.FileName);
BinaryReader binaryData = new BinaryReader(new FileStream(ImagePath, FileMode.Open, FileAccess.Read));
//aqui creaba un arreglo de bytes para almacenar los datos
imageData = new byte[binaryData.BaseStream.Length];
//y aqui leia los datos dentro del arreglo
binaryData.BaseStream.Read(imageData, 0, Convert.ToInt32(binaryData.BaseStream.Length));
SQLiteConnectionStringBuilder builder = new SQLiteConnectionStringBuilder();
builder.DataSource = DatabasePath;
using(SQLiteConnection connection = new SQLiteConnection(builder.ToString()))
{
connection.Open();
using(SQLiteTransaction transaction = connection.BeginTransaction())
{
using(SQLiteCommand command = new SQLiteCommand("INSERT INTO imagenes(pictures) VALUES (@pictures)", connection, transaction)) {
try
{
command.Parameters.AddWithValue("@pictures", imageData);
command.ExecuteNonQuery();
}
catch (Exception error)
{
MessageBox.Show(error.Message.ToString());
}
finally
{
transaction.Commit();
connection.Close();
}
}
}
}
System.UnauthorizedAccessException: Acceso denegado a la ruta de acceso 'c:\'.
en System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
en System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath)
en System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
en System.IO.File.ReadAllBytes(String path)
en prueba_visor.inicio.Button1Click(Object sender, EventArgs e) en c:\Users\Marto\Documents\SharpDevelop Projects\prueba_visor\prueba_visor\inicio.cs:línea 79
en System.Windows.Forms.Control.OnClick(EventArgs e)
en System.Windows.Forms.Button.OnClick(EventArgs e)
en System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
en System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
en System.Windows.Forms.Control.WndProc(Message& m)
en System.Windows.Forms.ButtonBase.WndProc(Message& m)
en System.Windows.Forms.Button.WndProc(Message& m)
en System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
en System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
en System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
string ImagePath = Path.GetFullPath(openImage.FileName);
BinaryReader binaryData = new BinaryReader(new FileStream(ImagePath, FileMode.Open, FileAccess.Read));