title: This is my code, a new photo is added, but the previous photo is not deleted Does anyone know what the problem is?
body: <pre><code>[HttpPost]
          [ValidateAntiForgeryToken]
          public ActionResult Edit([Bind(Include = &quot;Productid,Groupid,Productname,ProductText,Productimage,Productprice,Productdate&quot;)] Products products,HttpPostedFileBase Productimage)
          {
              if (ModelState.IsValid)
              {
                  if(Productimage != null)
                  {
                      if (products.Productimage != null)
                      {
                          System.IO.File.Delete(Server.MapPath(&quot;/Content/images/&quot;) + products.Productimage);
                      }
                      products.Productimage = Guid.NewGuid() + Path.GetExtension(Productimage.FileName);
                      Productimage.SaveAs(Server.MapPath(&quot;/Content/images/&quot;+products.Productimage));
                  }
                  db.Entry(products).State = EntityState.Modified;
                  db.SaveChanges();
                  return RedirectToAction(&quot;Index&quot;);
              }
              ViewBag.Groupid = new SelectList(db.Groups, &quot;Groupid&quot;, &quot;Grouptitle&quot;, products.Groupid);
              return View(products);
          }
  </code></pre>