c# 打开文件库

using (OpenFileDialog ofd = new OpenFileDialog())
                    {
                        ofd.Title = "请选择要插入的图片";
                        ofd.Filter = "JPG图片|*.jpg|BMP图片|*.bmp|Gif图片|*.gif";
                        ofd.CheckFileExists = true;
                        ofd.CheckPathExists = true;
                        ofd.Multiselect = false;

                        if (ofd.ShowDialog() == DialogResult.OK)
                        {
                             path = ofd.FileName;
                            picHeadImg.ImageLocation = path; //PictureBox
                             

                        }
                        else

                        {

                            MessageBox.Show("你没有选择图片", "信息提示");

                        }

                    }

猜你喜欢

转载自www.cnblogs.com/ruiyuan/p/11445692.html