SaveFileDialog sdlg = new SaveFileDialog();
sdlg.Title = "Select a file name to save Image";
sdlg.Filter = "JPEG File|*.jpg|Bitmap|*.bmp|GIF|*.gif|All File|*.*";
if (sdlg.ShowDialog() != DialogResult.Cancel)
{
Application.DoEvents();
// System.IO.FileInfo f = new System.IO.FileInfo(sdlg.FileName);
switch (System.IO.Path.GetExtension(sdlg.FileName).ToLower())
{
case ".jpg":
pictureBox1.Image.Save(sdlg.FileName, System.Drawing.Imaging.ImageFormat.Jpeg);
break;
case ".bmp":
pictureBox1.Image.Save(sdlg.FileName, System.Drawing.Imaging.ImageFormat.Bmp );
break;
case ".gif":
pictureBox1.Image.Save(sdlg.FileName, System.Drawing.Imaging.ImageFormat.Gif);
break;
default:
break;
}
}
No comments:
Post a Comment