RoadFlow2.1 临时演示

Delete.ashx.cs 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.IO;
  6. using System.Web.SessionState;
  7. namespace WebForm.Controls.UploadFiles
  8. {
  9. /// <summary>
  10. /// Delete 的摘要说明
  11. /// </summary>
  12. public class Delete : IHttpHandler,IReadOnlySessionState
  13. {
  14. public void ProcessRequest(HttpContext context)
  15. {
  16. context.Response.ContentType = "text/plain";
  17. string str1 = context.Request.QueryString["str1"];
  18. string str2 = context.Request.QueryString["str2"];
  19. var obj = RoadFlow.Cache.IO.Opation.Get(str1 ?? "");
  20. if (str1.IsNullOrEmpty() || str2.IsNullOrEmpty() || obj == null || obj.ToString() != str2)
  21. {
  22. context.Response.Write("var json = {\"success\":0,\"message\":\"您不能删除文件\"}");
  23. return;
  24. }
  25. string file = context.Request.QueryString["file"];
  26. if (!file.IsNullOrEmpty())
  27. {
  28. try
  29. {
  30. System.IO.File.Delete(context.Server.MapPath(Path.Combine("/Files/UploadFiles/", file)));
  31. context.Response.Write("var json = {\"success\":1,\"message\":\"\"}");
  32. }
  33. catch (Exception e)
  34. {
  35. context.Response.Write("var json = {\"success\":0,\"message\":\"" + e.Message + "\"}");
  36. }
  37. }
  38. context.Response.Write("");
  39. }
  40. public bool IsReusable
  41. {
  42. get
  43. {
  44. return false;
  45. }
  46. }
  47. }
  48. }