protected void btnExit_Click1(object sender, ImageClickEventArgs e) { try { int fileId = Convert.ToInt32(Request.QueryString["fileId"]); MyOffice.Models.FileInfo file = FileInfoManager.GetFileByFileId(fileId); if (Directory.Exists(this.lblFilePath.Text)) { Directory.Delete(this.lblFilePath.Text, true); } IList <int> childFileLists = new List <int>(); FileInfoManager.GetAllChildByFileId(childFileLists, Convert.ToInt32(Request.QueryString["fileId"])); foreach (int delfileId in childFileLists) { FileInfoManager.DelFileById(delfileId); } FileInfoManager.DelFileById(Convert.ToInt32(Request.QueryString["fileId"])); Response.Redirect("FileMain.aspx?fileId=" + file.ParentId + "&fileTypeId=1"); } catch (Exception ex) { throw; } }
protected void btnExit_Click(object sender, ImageClickEventArgs e) { try { int fileId = Convert.ToInt32(Request.QueryString["fileId"]); MyOffice.Models.FileInfo file = FileInfoManager.GetFileByFileId(fileId); if (File.Exists(this.lblFilePath.Text)) { File.Delete(this.lblFilePath.Text); } FileInfoManager.DelFileById(fileId); Response.Redirect("FileMain.aspx?fileId=" + file.ParentId + "&fileTypeId=1"); } catch (Exception ex) { throw; } }
protected void gvFileDelete_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "revert") { int fileId = Convert.ToInt32(e.CommandArgument); FileInfoManager.revert_IfDelete_ByFileId(fileId); this.gvFileDelete.DataBind(); } else if (e.CommandName == "del") { try { int fileId = Convert.ToInt32(e.CommandArgument); FileInfo file = FileInfoManager.GetFileByFileId(fileId); //从本地删除文件(夹) if (file.FileType.FileTypeId == 1) { System.IO.Directory.Delete(IniFile.IniReadValue(((MyOffice.Models.User)Session["Login"]).UserId) + file.FilePath, true); } else { System.IO.File.Delete(IniFile.IniReadValue(((MyOffice.Models.User)Session["Login"]).UserId) + file.FilePath); } //将要删除的子(子)文件集合 如果被删除的是文件 delLists.count为0 IList <int> delLists = new List <int>(); FileInfoManager.GetAllChildByFileId(delLists, fileId); //先删除本文件(夹) FileInfoManager.DelFileById(fileId); //如果是文件夹则要删除其下所有文件(夹) foreach (int delFileId in delLists) { FileInfoManager.DelFileById(delFileId); } this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('删除成功!');location='RecycleBin.aspx'</script>"); } catch { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('删除失败!');location='RecycleBin.aspx'</script>"); } } }