C#,保存winform中pictureBox中的图片
SaveFileDialog savedialog = new SaveFileDialog();
savedialog.Title = "附件另存";
savedialog.Filter = "jpg图片|*.JPG|png图片|Bmp 图片|*.bmp|*.PNG|jpeg图片|*.JPEG";
savedialog.FilterIndex = 3;//设置默认文件类型显示顺序
savedialog.RestoreDirectory = true; //点了保存按钮进入
if (pictureBox1.Image != null)
{
if (savedialog.ShowDialog() == DialogResult.OK)
{
string pictureName = savedialog.FileName;
//照片另存
using (MemoryStream mem = new MemoryStream())
{
Bitmap bmp = new Bitmap(pictureBox1.Image);
//保存到磁盘文件
bmp.Save(@pictureName, pictureBox1.Image.RawFormat);
bmp.Dispose();
MessageBox.Show("附件另存成功!", "注意", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
else
{
MessageBox.Show("没有附件信息!", "注意", MessageBoxButtons.OK, MessageBoxIcon.Information);
}