取日三省之意,记生活珠玑,每日清新,谓日新阁.
删除文件夹
1)
/***删除文件夹***/#region/***删除文件夹***/
/**//// <summary>
/// 删除文件夹
/// </summary>
public void Delete()
{
TreeNode node = _tree.SelectedNode;
DirectoryInfo dirObj = GetDirObj(node);
dirObj.Delete(true);//删除文件夹、其子文件夹与文件
this.DeleteSelectedNode();
this.FileLstCtl.Clear();
}
#endregion
/**//// <summary>
/// 删除选中的节点
/// </summary> private void DeleteSelectedNode()
{
try
{
_tree.Nodes.Remove(_tree.SelectedNode);
_tree.SelectedNode = null;
}
catch
{}
}
2)
/***删除***/#region/***删除***/
//删除
private void menuItem3_Click(object sender, System.EventArgs e)
{
string path= this.pre_Path + this.tv_Path.SelectedNode.FullPath;
//删除确认
DialogResult result=MessageBox.Show(this,"您确认要删除吗?","删除文件夹",
MessageBoxButtons.YesNo,
MessageBoxIcon.Question,MessageBoxDefaultButton.Button1);
if(result==DialogResult.Yes)
{
if(FoloderControl.DirectDel(path))
{
this.tv_Path.Nodes.Remove(this.tv_Path.SelectedNode);
//MessageBox.Show(this,"删除成功","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
}
}
#endregion