如何使用OpenFileDialog设置PictureBox控件的Image属性?
答案 0 :(得分:4)
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);
}