Beispiel #1
0
        public void deleteimage()
        {
            Host host = new Host();

             Image image = new Image();
             Utility utility = new Utility();
             HttpContext postedContext = HttpContext.Current;
             HttpFileCollection Files = postedContext.Request.Files;

             string serverKey = utility.Decode((string)postedContext.Request.Form["serverKey"]);
             string imageName = utility.Decode((string)postedContext.Request.Form["imgName"]);

             if (serverKey == utility.GetSettings("Server Key"))
             {
                  if (!image.ImageProtected(imageName))
                  {
                       try
                       {
                            if (Directory.Exists(utility.GetSettings("Image Store Path") + imageName))
                                 utility.DeleteAllFiles(utility.GetSettings("Image Store Path") + imageName);

                            if (Directory.Exists(utility.GetSettings("Image Hold Path") + imageName))
                                 utility.DeleteAllFiles(utility.GetSettings("Image Hold Path") + imageName);
                       }
                       catch (Exception ex)
                       {
                            Logger.Log(ex.Message);
                            HttpContext.Current.Response.Write("Could Not Delete Existing Image");
                       }

                       try
                       {
                            if (utility.GetSettings("Image Transfer Mode") == "udp+http")
                                 Directory.CreateDirectory(utility.GetSettings("Image Store Path") + imageName);
                            else
                                 Directory.CreateDirectory(utility.GetSettings("Image Hold Path") + imageName);
                       }
                       catch (Exception ex)
                       {
                            Logger.Log(ex.Message);
                            HttpContext.Current.Response.Write("Could Not Delete Existing Image");
                       }
                       HttpContext.Current.Response.Write("true");
                  }
                  else
                       HttpContext.Current.Response.Write("Image Is Protected");
             }
             else
                  HttpContext.Current.Response.Write("Server Key Did Not Match");
        }