コード例 #1
0
        void createDir(object sender, EventArgs e)
        {
            string     path;
            CreateView frm = new CreateView();

            try
            {
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    path = Path.Combine((LeftPathOnFocus ? LeftPath.Text : RightPath.Text), frm.dir.Text);
                    Directory.CreateDirectory(path);
                }
                ListViewUpdate(LeftPathOnFocus);
            }
            catch { MessageBox.Show("Невозможно создать каталог!", "Ошибка"); }
        }
コード例 #2
0
        void moveFile(object sender, EventArgs e)
        {
            try
            {
                string sourcePath, destinationPath;
                sourcePath      = LeftPathOnFocus ? Path.Combine(LeftPath.Text, LeftListView.SelectedItems[0].Text) : Path.Combine(RightPath.Text, RightListView.SelectedItems[0].Text);
                destinationPath = LeftPathOnFocus ? Path.Combine(RightPath.Text, LeftListView.SelectedItems[0].Text) : Path.Combine(LeftPath.Text, RightListView.SelectedItems[0].Text);

                if (sourcePath == destinationPath)
                {
                    CreateView frm = new CreateView();
                    frm.Text          = "Преименнование";
                    frm.txtLable.Text = "Введите новое имя";
                    frm.dir.Text      = LeftListView.SelectedItems[0].Text;
                    frm.okBtn.Text    = "Пререименовать";
                    if (frm.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }
                    else
                    {
                        destinationPath = Path.Combine(LeftPathOnFocus ? RightPath.Text : LeftPath.Text, frm.dir.Text);
                    }
                }
                if ((LeftPathOnFocus ? LeftListView.SelectedItems[0].SubItems[1].Text : RightListView.SelectedItems[0].SubItems[1].Text) == "Файл")
                {
                    File.Move(sourcePath, destinationPath);
                }
                else
                {
                    Directory.Move(sourcePath, destinationPath);
                }
            }
            catch { MessageBox.Show("Невозможно переместить файл! ", "Ошибка"); }
            finally
            {
                ListViewUpdate(true);
                ListViewUpdate(false);
            }
        }