Пример #1
0
        public void delete()
        {
            if (this.CurrentAdress == "")
            {
                return;
            }
            DirectoryInfo directoryInfo = new DirectoryInfo(this.CurrentAdress);

            DirectoryInfo[] directories = directoryInfo.GetDirectories();
            FileInfo[]      files       = directoryInfo.GetFiles();

            foreach (DirectoryInfo folder in directories)
            {
                try
                {
                    if (folder.Exists && folder.Name == this.view.SelectedItems[0].Text)
                    {
                        ImprovedFolder.Delete(folder.FullName);
                    }
                }
                catch (Exception) { }
            }
            foreach (FileInfo file in files)
            {
                if (this.view.SelectedItems.Count > 0 && file.Exists && file.Name == this.view.SelectedItems[0].Text)
                {
                    file.Delete();
                }
            }
            this.buildDirectories(this.CurrentAdress);
        }
Пример #2
0
        public void reName()
        {
            string     aim        = this.view.SelectedItems[0].Text;
            bool       isFile     = (aim.Split('.').Length > 1 ? true : false);
            string     from       = Path.Combine(currentAdress, aim);
            RenameForm renameForm = new RenameForm();

            renameForm.ShowDialog();
            if (renameForm.name != "")
            {
                bool isValidName = true;
                if (renameForm.name == aim)
                {
                    isValidName = false;
                }
                foreach (char x in renameForm.name)
                {
                    if (isValidName &&
                        (x == '/' || x == '\\' || x == '*' || x == ':' || x == '?' || x == '\"' ||
                         x == '<' || x == '>' || x == '|' || x == '.'))
                    {
                        isValidName = false;
                        break;
                    }
                }
                if (!isValidName)
                {
                    MessageBox.Show(MyStrings.WrongName);
                }
                else
                {
                    string to = Path.Combine(currentAdress, renameForm.name);
                    if (isFile)
                    {
                        var    arr = aim.Split('.');
                        string ext = arr[arr.Length - 1];
                        ImprovedFolder.MoveTo(this.currentAdress, aim, renameForm.name + "." + ext);
                    }
                    else
                    {
                        ImprovedFolder.MoveTo(this.currentAdress, aim, renameForm.name);
                    }
                }
            }
            this.buildDirectories(this.currentAdress);
        }
Пример #3
0
        public void pasteFromBuffer()
        {
            if (this.name == "" || this.CurrentAdress == "")
            {
                return;
            }
            string target;

            if (this.view.SelectedItems.Count == 0)
            {
                target = Path.Combine(this.CurrentAdress);
            }
            else
            {
                target = Path.Combine(this.CurrentAdress, Path.GetFileName(this.view.SelectedItems[0].Text));
            }
            ImprovedFolder.CopyTo(this.Buffer, target, name);
            this.buildDirectories(this.CurrentAdress);
        }