protected void ServerFileDelete_Click(object sender, EventArgs e) { //需要对该页面有执行权限 if (!WebUtil.CheckPrivilege(WebConfig.FunctionUpdateServerDispenseFiles, OpType.EXECUTE, Session)) { Response.Redirect(WebConfig.PageNotEnoughPrivilege, true); } LinkButton link = sender as LinkButton; int delId = int.Parse(link.ID.Substring(10)); string fileName = (ServerFileList.Rows[delId + 1].Cells[1].Controls[1] as Literal).Text; //string fileName = ServerFileList.Rows[delId + 1].Cells[1].Text; ServerFileInfo file = ftpServer.GetServerFileInfo(fileName); if (ftpServer != null && file != null) { if (file.Directory) { if (ftpServer.RemoveDir(ftpServer.RootUri + file.Name + "/")) { LabelOpMsg.Text = StringDef.Processing; } else { LabelOpMsg.Text = (StringDef.OperationFail + ftpServer.Result); } } else { LabelOpMsg.Text = StringDef.Processing; if (ftpServer.DeleteFile(fileName)) { LabelOpMsg.Text = StringDef.Processing; } else { LabelOpMsg.Text = (StringDef.OperationFail + ftpServer.Result); } } ftpServer.ListFile(); } }
protected void LinkButtonDeleteServerFile_Click(object sender, EventArgs e) { try { if (server != null) { //需要对该页面有执行权限 if (!WebUtil.CheckPrivilege(WebConfig.FunctionUpdateServerUpdateServerState, OpType.EXECUTE, Session)) { Response.Redirect(WebConfig.PageNotEnoughPrivilege, true); } LinkButton lb = sender as LinkButton; if (lb != null) { string path = ViewState[ParamPath] as string; StringBuilder msgBuilder = new StringBuilder(); foreach (DataGridItem item in DataGridServerFileList.Items) { CheckBox checkBox = item.Cells[0].FindControl("CheckBoxServerFile") as CheckBox; if (checkBox != null && checkBox.Checked) { LinkButton linkButtonFile = item.Cells[1].FindControl("LinkButtonViewDir") as LinkButton; if (linkButtonFile != null) { string fileName = linkButtonFile.Text; if (fileName != null && fileName.Length != 0) { ServerFileInfo file = server.GetServerFileInfo(fileName); if (file != null) { if (file.Directory) { if (server.RemoveDir(server.RootUri + path + file.Name + WebConfig.UpdateServerPathDelimiter)) { Thread.Sleep(DeleteServerFileDelayTime); msgBuilder.Append(string.Format("{0}[{1}]<br />", server.Result, file.Name)); } else { msgBuilder.Append(string.Format("[删除目录[{0}]失败]{1}<br />", file.Name, server.Result)); } } else { if (server.DeleteFile(path + fileName)) { Thread.Sleep(DeleteServerFileDelayTime); msgBuilder.Append(string.Format("{0}[{1}]<br />", server.Result, file.Name)); } else { msgBuilder.Append(string.Format("[删除文件[{0}]失败]{1}<br />", file.Name, server.Result)); } } } } } } } Message.Text += msgBuilder.Length == 0 ? StringDef.OperationSucceed : msgBuilder.ToString(); Message.Text += "<br />"; ListServerFiles(); Thread.Sleep(RefreshServerFilesDelayTime); GetServerFileList(); } } } catch (Exception ex) { FSEye.Util.DebugLog(ex.ToString()); } }