protected void btnRename_Click(object sender, EventArgs e) { if (!Page.IsValid) { RenameFileModal.Show(); return; } // move files string oldPath = GetFullRelativePath((string)ViewState["RenameFile"]); string newPath = GetFullRelativePath(txtRenameFile.Text); try { int result = ES.Services.Files.RenameFile(PanelSecurity.PackageId, oldPath, newPath); if (result < 0) { messageBox.ShowResultMessage(result); return; } } catch (Exception ex) { messageBox.ShowErrorMessage("FILES_RENAME_FILE", ex); } // hide form RenameFileModal.Hide(); gvFiles.DataBind(); }
protected void gvFiles_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "browse") { string fileName = (string)e.CommandArgument; litPath.Text += HttpContext.Current.Server.HtmlEncode((litPath.Text != "\\") ? ("\\" + fileName) : fileName); BindPath(); } else if (e.CommandName == "download") { string path = GetFullRelativePath((string)e.CommandArgument); Response.Redirect(NavigateURL(PortalUtils.SPACE_ID_PARAM, PanelSecurity.PackageId.ToString(), "DownloadFile=" + Server.UrlEncode(path))); } else if (e.CommandName == "edit_file") { // read file content try { string path = GetFullRelativePath((string)e.CommandArgument); ViewState["EditFile"] = path; txtEditFileContent.Text = GetFileContent(path, ddlFileEncodings.SelectedValue); // show edit panel EditFileModal.Show(); } catch (Exception ex) { messageBox.ShowErrorMessage("FILES_READ_FILE", ex); } } else if (e.CommandName == "edit_permissions") { // read file content try { string path = GetFullRelativePath((string)e.CommandArgument); ViewState["EditPermissions"] = path; UserPermission[] users = ES.Services.Files.GetFilePermissions(PanelSecurity.PackageId, path); gvFilePermissions.DataSource = users; gvFilePermissions.DataBind(); // show permissions panel PermissionsFileModal.Show(); } catch (Exception ex) { messageBox.ShowErrorMessage("FILES_READ_PERMISSIONS", ex); } } else if (e.CommandName == "rename") { RenameFileModal.Show(); ViewState["RenameFile"] = (string)e.CommandArgument; txtRenameFile.Text = (string)e.CommandArgument; } }