OpenFileDialog openFileDlg = new OpenFileDialog();
            openFileDlg.Title = "选择文件";
            openFileDlg.Multiselect = false;
            openFileDlg.InitialDirectory=Environment.GetFolderPath(Environment.SpecialFolder.Desktop);//设置默认路径为桌面
            openFileDlg.Filter = "(*.jpg,*.png,*.jpeg,*.bmp,*.gif)|*.jgp;*.png;*.jpeg;*.bmp;*.gif|All files(*.*)|*.*"; //设置多文件格式
            if (openFileDlg.ShowDialog() == DialogResult.OK)
            {
                String filePath = openFileDlg.FileName;
                this.pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
                this.pictureBox1.ImageLocation = filePath;//选择照片后在PictureBox中显示
          }

 

相关文章:

  • 2021-04-14
  • 2022-12-23
  • 2021-07-16
  • 2021-08-01
  • 2022-12-23
  • 2021-05-28
  • 2022-01-07
猜你喜欢
  • 2022-12-23
  • 2022-02-03
  • 2021-07-30
  • 2022-12-23
  • 2021-05-09
  • 2022-12-23
  • 2021-08-25
相关资源
相似解决方案