Exemple #1
0
        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);
                    }
                }
            }
        }