Exemplo n.º 1
0
        /// <summary>
        /// 右键菜单删除事件
        /// </summary>
        private void item_del_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("是否继续删除?", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (result == DialogResult.Yes)
            {
                SelectedItemsStatus status = GetStatusOfSelectedItemsInListView();
                if (status == SelectedItemsStatus.IsDir)
                {
                    string webDir = GetSelectedPathInListView(true);
                    _fileManager.DeleteFileOrDir(webDir);
                }
                else if (status == SelectedItemsStatus.IsFile)
                {
                    string webFile = GetSelectedPathInListView(false);
                    _fileManager.DeleteFileOrDir(webFile);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 右键菜单删除事件
        /// </summary>
        private void item_del_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Continue To Delete?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (result == DialogResult.Yes)
            {
                List <FileInfo>     fileInfos = GetSelectedFilesInListView();
                SelectedFilesStatus status    = GetStatusOfSelectedFilesInListView(fileInfos);
                if (status == SelectedFilesStatus.IsDir || status == SelectedFilesStatus.IsFile)
                {
                    string webDir = fileInfos[0].FullName;
                    //提前删除文件夹节点,如果删除失败可能会影响(待解决)
                    RemoveDirInDirTree(treeView_Dirs, webDir, _isWin);
                    _fileManager.DeleteFileOrDir(webDir);
                }
            }
        }