Here I would make an indecent use of the
using
keyword. This way :
#region create thumnail
string src = Server.MapPath("~/" + RadComboBox1.SelectedValue.ToString() + "/images/" + validFile.FileName);
using (System.Drawing.Image image = System.Drawing.Image.FromFile(src))
using (Bitmap bmp = new Bitmap(110, 74))
using (System.Drawing.Graphics gr = System.Drawing.Graphics.FromImage(bmp))
{
int srcWidth = image.Width;
int srcHeight = image.Height;
gr.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
gr.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
gr.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
System.Drawing.Rectangle rectDestination = new System.Drawing.Rectangle(0, 0, 110, 74);
gr.DrawImage(image, rectDestination, 0, 0, srcWidth, srcHeight, GraphicsUnit.Pixel);
string dest = <destination file name from your scheme>;
bmp.Save(dest);
}
#endregion
This way everything that has to be is cleaned up at the end of the process, without having to close/dispose anything ;
using
will handle that for you.