private void SaveBitmap(Bitmap bmp) { if (!String.IsNullOrEmpty(ScreenCapBgLocText.Text) && !String.IsNullOrEmpty(_imgExt)) { try { string outPath = ScreenCapBgLocText.Text; DirectoryInfo dir = new DirectoryInfo(outPath); FileInfo[] files = dir.GetFiles(); int i = 0; string name = "BrawlboxScreencap"; Top: foreach (FileInfo f in files) if (f.Name == name + i + _imgExt) { i++; goto Top; } outPath += "\\" + name + i + _imgExt; bool okay = true; if (_imgExt.Equals(".png")) bmp.Save(outPath, ImageFormat.Png); else if (_imgExt.Equals(".tga")) bmp.SaveTGA(outPath); else if (_imgExt.Equals(".tiff") || _imgExt.Equals(".tif")) bmp.Save(outPath, ImageFormat.Tiff); else if (_imgExt.Equals(".bmp")) bmp.Save(outPath, ImageFormat.Bmp); else if (_imgExt.Equals(".jpg") || outPath.EndsWith(".jpeg")) bmp.Save(outPath, ImageFormat.Jpeg); else if (_imgExt.Equals(".gif")) bmp.Save(outPath, ImageFormat.Gif); else { okay = false; } if (okay) MessageBox.Show("Screenshot successfully saved to " + outPath.Replace("\\", "/")); } catch { } } bmp.Dispose(); }