private void RenameLocalFolder() { if (GridViewLocalFiles.SelectedRowsCount > 0) { string oldFolderName = GridViewLocalFiles.GetRowCellValue(GridViewLocalFiles.FocusedRowHandle, "Name").ToString(); string oldFolderPath = TextBoxLocalPath.Text + @"\" + oldFolderName; string newFolderName = StringExtensions.ReplaceInvalidChars(DialogExtensions.ShowTextInputDialog(this, "Rename Folder", "Folder Name:", oldFolderName)); string newFolderPath = TextBoxLocalPath.Text + @"\" + newFolderName; if (newFolderName != null && !newFolderName.Equals(oldFolderName)) { if (!Directory.Exists(newFolderPath)) { SetLocalStatus("A folder with this name already exists."); } else { SetLocalStatus($"Renaming folder to: {newFolderName}"); FileSystem.RenameDirectory(oldFolderPath, newFolderName); SetLocalStatus($"Successfully renamed folder to: {newFolderName}"); LoadLocalDirectory(DirectoryPathLocal); } } } }
private void GridViewLocalFiles_DoubleClick(object sender, EventArgs e) { if (GridViewLocalFiles.SelectedRowsCount > 0) { string type = GridViewLocalFiles.GetRowCellValue(GridViewLocalFiles.FocusedRowHandle, "Type").ToString(); string name = GridViewLocalFiles.GetRowCellValue(GridViewLocalFiles.FocusedRowHandle, "Name").ToString(); if (name == "..") { string trimLastIndex = Path.GetDirectoryName(DirectoryPathLocal).TrimEnd('\\'); string parentDirectory = trimLastIndex.Substring(0, trimLastIndex.LastIndexOf(@"\")) + @"\"; if (Directory.Exists(parentDirectory)) { LoadLocalDirectory(parentDirectory); } } else if (type == "folder") { LoadLocalDirectory(DirectoryPathLocal + @"\" + name + @"\"); } ButtonLocalOpenExplorer.Enabled = Directory.Exists(TextBoxLocalPath.Text); } }
private void GridViewLocalFiles_RowClick(object sender, RowClickEventArgs e) { if (GridViewLocalFiles.SelectedRowsCount > 0) { string type = GridViewLocalFiles.GetRowCellValue(e.RowHandle, "Type").ToString(); string name = GridViewLocalFiles.GetRowCellValue(e.RowHandle, "Name").ToString(); ButtonLocalUpload.Enabled = type == "file" && name != ".."; ButtonLocalDelete.Enabled = type == "file" | type == "folder" && name != ".."; ButtonLocalRename.Enabled = type == "file" | type == "folder" && name != ".."; } }
public void UploadLocalFile() { try { string type = GridViewLocalFiles.GetRowCellValue(GridViewLocalFiles.FocusedRowHandle, "Type").ToString(); string name = GridViewLocalFiles.GetRowCellValue(GridViewLocalFiles.FocusedRowHandle, "Name").ToString(); if (type.Equals("file")) { string localPath = TextBoxLocalPath.Text + name; string consolePath = TextBoxConsolePath.Text + name; if (File.Exists(localPath)) { SetLocalStatus($"Uploading file to {consolePath}..."); if (ConsoleType == ConsoleTypePrefix.PS3) { FtpExtensions.UploadFile(localPath, consolePath); } else { XboxConsole.SendFile(localPath, consolePath); } SetLocalStatus($"Successfully uploaded file: {Path.GetFileName(localPath)}"); LoadConsoleDirectory(DirectoryPathConsole); } else { SetLocalStatus("Unable to upload file as it doesn't exist on your computer."); } } else if (type.Equals("folder")) { string localPath = TextBoxLocalPath.Text + name + @"\"; string consolePath = TextBoxConsolePath.Text + name; SetLocalStatus($"Uploading folder to {consolePath}..."); //FtpClient.UploadDirectory(localPath, consolePath, FtpFolderSyncMode.Update, FtpRemoteExists.Overwrite); SetLocalStatus($"Successfully uploaded folder: {localPath}"); LoadConsoleDirectory(DirectoryPathConsole); } } catch (Exception ex) { SetLocalStatus($"Unable to upload to console. Error: {ex.Message}", ex); } }
private void ButtonLocalRename_Click(object sender, EventArgs e) { string type = GridViewLocalFiles.GetRowCellValue(GridViewLocalFiles.FocusedRowHandle, "Type").ToString(); switch (type) { case "folder": RenameLocalFolder(); break; case "file": RenameLocalFile(); break; } }
public void DeleteLocalItem() { try { if (XtraMessageBox.Show("Do you really want to delete the selected item?", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { string type = GridViewLocalFiles.GetRowCellValue(GridViewLocalFiles.FocusedRowHandle, "Type").ToString(); string name = GridViewLocalFiles.GetRowCellValue(GridViewLocalFiles.FocusedRowHandle, "Name").ToString(); if (!name.Equals("..")) { string selectedItem = TextBoxLocalPath.Text + @"\" + name; if (type.Equals("folder")) { SetLocalStatus($"Deleting folder: {selectedItem}"); UserFolders.DeleteDirectory(selectedItem); SetLocalStatus($"Successfully deleted folder: {name}"); } else if (type.Equals("file")) { if (File.Exists(selectedItem)) { SetLocalStatus($"Deleting file: {selectedItem}"); File.Delete(selectedItem); SetLocalStatus($"Successfully deleted file: {name}"); } } } GridViewLocalFiles.DeleteRow(GridViewLocalFiles.FocusedRowHandle); } } catch (Exception ex) { SetLocalStatus($"Unable to delete item. Error: {ex.Message}", ex); } }