Open image files in C#
Step - Add one PictureBox and button from the toolbox and then go to the button1_click event and copy the following code.
using System;
using System. Drawing;
using System.Windows.Forms;
using System.IO;
private void button1_Click(object sender, EventArgs e)
{
using (OpenFileDialog openFileDialog1 = new OpenFileDialog())
{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
pictureBox1.Image = Image.FromFile(openFileDialog1.FileName);
}
}
}
No comments:
Post a Comment