界面
代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace XXX
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1UploadImage_Click(object sender, EventArgs e)
{
using (OpenFileDialog imgFile = new OpenFileDialog())
{
if (imgFile.ShowDialog() == DialogResult.OK)
{
string fileName = imgFile.FileName;
this.pictureBox1.Image = Image.FromFile(fileName);
label1.Text = fileName;
}
}
}
}
}
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
效果