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