My problem is that when I click on the open button I want it to open automatically, it can be seen, and serialized with the * .poo path in the same location where I opened the image, all this only with the button open, since I want to delete the deserialize button.
Any suggestions on how to do that?
private void btnAbrir_Click(object sender, EventArgs e)
{
OpenFileDialog ventana = new OpenFileDialog();
ventana.Filter = "Archivo JPG|*.jpg|Archivo PNG|*.png";
if (ventana.ShowDialog() == DialogResult.OK)
{
this.pictureBox1.Image = System.Drawing.Bitmap.FromFile(ventana.FileName);
}
}
private void btnserializar1_Click(object sender, EventArgs e)
{
SaveFileDialog ventana = new SaveFileDialog();
ventana.Filter = "Archivo Binario|*.poo";
if(ventana.ShowDialog()==DialogResult.OK)
{
FileStream fichero = new FileStream(ventana.FileName,FileMode.Create);
BinaryFormatter formatoBinario = new BinaryFormatter();
formatoBinario.Serialize(fichero, this.pictureBox1.Image);
fichero.Close();
MessageBox.Show("Serializado Okey");
}
}
private void btndeserializar1_Click(object sender, EventArgs e)
{
OpenFileDialog ventana = new OpenFileDialog();
ventana.Filter = "Archivo Binario|*.poo";
if (ventana.ShowDialog() == DialogResult.OK)
{
FileStream fichero = new FileStream(ventana.FileName, FileMode.Open);
BinaryFormatter formatoBinario = new BinaryFormatter();
this.pictureBox1.Image = (Bitmap)formatoBinario.Deserialize(fichero);
fichero.Close();
MessageBox.Show("Deserializado Okey");
}
}