예제 #1
0
        private void Rename_Click(object sender, RoutedEventArgs e)
        {
            Models.FileSystemItem item = (Models.FileSystemItem)((Button)sender).DataContext;
            string      oldName        = CurrentFolder + "\\" + item.Name;
            InputWindow inputWindow    = new InputWindow(Properties.Resources.RenameText, "Rename");
            string      newName        = inputWindow.getInput();

            if (newName == null)
            {
                return;
            }
            newName = CurrentFolder + "\\" + newName;
            if (item.Type.Equals("Folder"))
            {
                try
                {
                    new DirectoryInfo(oldName).MoveTo(newName);
                }
                catch (IOException)
                {
                    MessageBox.Show(Properties.Resources.RenameFail, "Rename Fail");
                }
            }
            else
            {
                try
                {
                    new FileInfo(oldName).MoveTo(newName);
                }
                catch (IOException)
                {
                    MessageBox.Show(Properties.Resources.RenameFail, "Rename Fail");
                }
            }
        }
예제 #2
0
        private void Create_Click(object sender, RoutedEventArgs e)
        {
            InputWindow inputWindow = new InputWindow(Properties.Resources.InputFolderName, "Create New Folder");
            string      folderName  = inputWindow.getInput();

            if (folderName != null && !Directory.Exists(CurrentFolder + "\\" + folderName))
            {
                try
                {
                    Directory.CreateDirectory(CurrentFolder + "\\" + folderName);
                }
                catch (IOException)
                {
                    MessageBox.Show(Properties.Resources.PathIllegal, "Create New Folder Error");
                }
            }
        }