public void openDialog() { Stream myStream = null; OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.InitialDirectory = "c:\\"; openFileDialog1.Filter = "All files (*.*)|*.*"; openFileDialog1.FilterIndex = 2; openFileDialog1.RestoreDirectory = true; openFileDialog1.FileName = System.IO.Path.ChangeExtension(openFileDialog1.FileName, "png"); if (openFileDialog1.ShowDialog() == DialogResult.OK) //aqui es donde me marca error { try { if ((myStream = openFileDialog1.OpenFile()) != null) { using (myStream) { nombre= openFileDialog1.FileName; pictureBox1.Image = Image.FromFile(@nombre); } } } catch (Exception ex) { MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message); } } }
public OleDbConnection ObtenerConexion() { OleDbConnection Conexion = new OleDbConnection(); try { String connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;" + "Data Source=GS.accdb"; Conexion = new OleDbConnection(connectionString); Conexion.Open(); } catch (Exception e) { Console.WriteLine(e.Message); Conexion.Close(); } return Conexion; }
private void Form1_FormClosed(object sender, FormClosedEventArgs e) { Application.ExitThread(); }