如何通过使用OpenFileDialog设置PictureBox控件的Image属性?
Set PictureBox.Image
using Image.FromFile
OpenFileDialog _openFileDialog = new OpenFileDialog();
_openFileDialog.FileOk += OpenFileDialogFileOk;
_openFileDialog.CheckFileExists = true;
_openFileDialog.CheckPathExists = true;
_openFileDialog.ShowDialog();
void OpenFileDialogFileOk(object sender, CancelEventArgs e)
{
var imageInformation = new FileInfo(_openFileDialog.FileName);
var sizeInBytes = imageInformation.Length;
myPictureBox.Image = Image.FromFile(_openFileDialog.FileName);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.