美文网首页
C# 打开图片格式文件

C# 打开图片格式文件

作者: a9b854aded01 | 来源:发表于2017-11-13 14:12 被阅读0次
public string GetImageFromLocalPath()
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Title = "请选择要上传的图片";
            ofd.Filter = "JPG图片|*.jpg|PNG图片|*.png|Gif图片|*.gif";
            ofd.CheckFileExists = true;

            ofd.CheckPathExists = true;
            ofd.Multiselect = false;
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                this.txtPath.Text = ofd.FileName;
                this.pbSeal.Image = Image.FromFile(ofd.FileName);
                FileStream file = new FileStream(this.txtPath.Text, FileMode.Open, FileAccess.Read);
                Byte[] bytBLOBData = new Byte[file.Length];
                file.Read(bytBLOBData, 0, bytBLOBData.Length);
                file.Close();
                this.ImageCur = bytBLOBData;
                return ofd.FileName;
            }
            return "";

        }

相关文章

网友评论

      本文标题:C# 打开图片格式文件

      本文链接:https://www.haomeiwen.com/subject/hvlzmxtx.html