public void ExportToBmp(string path) { using (var bitmap = new Bitmap(diag.Width, diag.Height)) { diag.DrawToBitmap(bitmap, diag.ClientRectangle); ImageFormat imageFormat = null; var extension = Path.GetExtension(path); switch (extension) { case ".bmp": imageFormat = ImageFormat.Bmp; break; case ".png": imageFormat = ImageFormat.Png; break; case ".jpeg": case ".jpg": imageFormat = ImageFormat.Jpeg; break; case ".gif": imageFormat = ImageFormat.Gif; break; default: throw new NotSupportedException("Dateiendung wird nicht unterstützt!"); } try { bitmap.Save(path, imageFormat); } catch (Exception ex) { MessageBox.Show("Bild kann nicht abgespeichert werden!"); } } }