if (!File.Exists(Server.MapPath("~/ItemImage/" + Convert.ToString(Request.QueryString["compid"]) + "/" + Convert.ToString(Request.QueryString["offID"]) + "/" + itemImgName))) { string newImgName = Convert.ToString(itemID); FileUpload file = new FileUpload(); FileInfo fileIn = new FileInfo(Server.MapPath("~/ItemImage/" + Convert.ToString(Request.QueryString["compid"]) + "/" + Convert.ToString(Request.QueryString["offID"]) + "/" + itemImgName)); fileIn.Name.Replace(itemImgName + "." + fileExt, newImgName + "." + fileExt); newImgName = newImgName + "." + fileExt; new DAL.DatabaseActivities().ExecuteNonQuery("Update EBS_Client"+_compId+".dbo.ItemMaster set ItemImage='"+newImgName+"' where Item_Id="+itemID+""); //file.SaveAs(Server.MapPath("~/ItemImage/" + Convert.ToString(Request.QueryString["compid"]) + "/" + Convert.ToString(Request.QueryString["offID"]) + "/" + file.FileName.Replace(itemImgName, newImgName))); }