C#中saveFileDialog的操作

this.saveFileDialog.Title = "保存为";
this.saveFileDialog.InitialDirectory = Application.StartupPath + @"..\..\图片";
this.saveFileDialog.FileName = "";
saveFileDialog.RestoreDirectory = true;
this.saveFileDialog.Filter = "图片(.png)|*.png";
if (this.saveFileDialog.ShowDialog() == DialogResult.OK)
{
Bitmap bit = new Bitmap(this.Width, this.Height);//实例化一个和窗体一样大的bitmap
Graphics g = Graphics.FromImage(bit);
g.CompositingQuality = CompositingQuality.HighQuality;//质量设为最高
g.CopyFromScreen(this.Left, this.Top, 0, 0, new Size(this.Width, this.Height));//保存整个窗体为图片

}
else
{
MessageBox.Show("保存失败");
return;
}
怎么不可以存

你根本就没写保存代码怎么存,在

g.CopyFromScreen(this.Left, this.Top, 0, 0, new Size(this.Width, this.Height));//保存整个窗体为图片

后面加一行

g.CopyFromScreen(this.Left, this.Top, 0, 0, new Size(this.Width, this.Height));//保存整个窗体为图片
bit.Save(saveFileDialog.FileName,System.Drawing.Imaging.ImageFormat.Png);

温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答