首页 > 解决方案 > 当我单击按钮时,OpenFileDialog 冻结应用程序/GUI

问题描述

我已经看到了有关此问题的多个问题并尝试了几种解决方案,但似乎都没有奏效,也许我错过了一些东西。

private void ButtonBrowseProfile_Click(object sender, EventArgs e)
{
     using(OpenFileDialog openFileDialog = new OpenFileDialog())
     {
          openFileDialog.Title = "Upload Profile Image";
          openFileDialog.Filter = "Image Files(*.jpg;*.jpeg;*.gif;*.bmp;*.png)|*.jpg;*.jpeg;*.gif;*.bmp;*.png";
          if (openFileDialog.ShowDialog() == DialogResult.OK)
               pictureBoxProfile.Image = new Bitmap(openFileDialog.FileName);
     }
}

对话框不显示,调试应用程序只是冻结并变得不可点击

WinForm,.NET 框架 4.8 | 528040

标签: c#.netopenfiledialog

解决方案


推荐阅读