protected void Copy(object sender, EventArgs e) { if (!CurrentUser.OperateFiles) { Response.StatusCode = 401; return; } foreach (var source in SelectedPaths) { FileHelper.Copy(source, FileHelper.Combine(Hidden.Value.UrlDecode(), Path.GetFileName(source)), false); } Response.Redirect(Request.RawUrl); }
protected void Page_Load(object sender, EventArgs e) { Response.Clear(); Response.ContentType = "application/xml"; var result = new XElement("result"); var path = RouteData.GetRelativePath(); try { switch (RouteData.GetRouteString("Action").ToLower()) { case "list": if (!Request.GetUser().Browse) { Response.StatusCode = 401; return; } List(path, result); break; case "createdirectory": if (!Request.GetUser().OperateFiles) { Response.StatusCode = 401; return; } FileHelper.CreateDirectory(path); break; case "copy": if (!Request.GetUser().OperateFiles) { Response.StatusCode = 401; return; } FileHelper.Copy(path, Request.QueryString["Target"].UrlDecode()); break; case "move": if (!Request.GetUser().OperateFiles) { Response.StatusCode = 401; return; } FileHelper.Move(path, Request.QueryString["Target"].UrlDecode()); break; case "delete": if (!Request.GetUser().OperateFiles) { Response.StatusCode = 401; return; } FileHelper.Delete(path); break; case "details": if (!Request.GetUser().Browse) { Response.StatusCode = 401; return; } Details(path, result); break; case "niguan": NiGuan(path, result); Response.Write(result.ToString()); return; case "codecs": Codecs(result); break; default: throw new FormatException("无法识别的 Action!"); } result.SetAttributeValue("status", "ok"); } catch (Exception exc) { result.SetAttributeValue("status", "error"); result.SetAttributeValue("message", exc.GetMessage()); } Response.Write(result.ToString()); }