C# 打开图片格式文件
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
网友评论