Declare this:
Byte[] b = null;
FileStream Fs = default(FileStream);
Inserting Image:
private void Picturebox1_Click(object sender, EventArgs e)
{
try
{
OpenFileDialog dialog = new OpenFileDialog();
dialog.Filter = "JPEG(*.jpeg)|*.jpeg|GIF(*.gif)|*.gif|PNG(*.Png)|*.png|AllFiles|*.*";
if (dialog.ShowDialog() == DialogResult.OK)
{
Fs = File.Open(dialog.FileName, FileMode.OpenOrCreate);
b = new Byte[Fs.Length];
Fs.Read(b, 0, b.Length);
Fs.Close();
Picturebox1.Image = Image.FromFile(dialog.FileName);
}
else
{
MessageBox.Show("Select Image", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}