RoadFlow2.1 临时演示

File.ashx.cs 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Xml.Linq;
  6. using System.IO;
  7. namespace WebForm.Controls.SelectIco
  8. {
  9. /// <summary>
  10. /// File 的摘要说明
  11. /// </summary>
  12. public class File : IHttpHandler
  13. {
  14. public void ProcessRequest(HttpContext context)
  15. {
  16. context.Response.ContentType = "text/plain";
  17. context.Response.Expires = 0;
  18. context.Response.Buffer = true;
  19. context.Response.Clear();
  20. context.Response.ContentType = "text/xml";
  21. XElement rootElement = new XElement("Root");
  22. string Path = context.Request["Path"];
  23. string Path1 = Common.Tools.BaseUrl + Path;
  24. string showType = ",.jpg,.gif,.png,";
  25. if (!Directory.Exists(context.Server.MapPath(Path1)))
  26. {
  27. rootElement.Save(context.Response.Output);
  28. context.Response.End();
  29. }
  30. DirectoryInfo folder = new DirectoryInfo(context.Server.MapPath(Path1));
  31. XElement element;
  32. foreach (var item in folder.GetFiles().Where(p => (p.Attributes & FileAttributes.Hidden) == 0))
  33. {
  34. if (showType.IndexOf("," + item.Extension.ToLower() + ",") != -1)
  35. {
  36. element = new XElement("Icon");
  37. rootElement.Add(element);
  38. element.SetAttributeValue("title", item.Name);
  39. element.SetAttributeValue("path", Path1.Replace(@"\", "/") + "/" + item.Name);
  40. element.SetAttributeValue("path1", Path.Replace(@"\", "/") + "/" + item.Name);
  41. }
  42. }
  43. rootElement.Save(context.Response.Output);
  44. context.Response.End();
  45. }
  46. public bool IsReusable
  47. {
  48. get
  49. {
  50. return false;
  51. }
  52. }
  53. }
  54. }