1)
/***删除文件夹***/
#region/***删除文件夹***/
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
/// 删除文件夹
/// </summary>
public void Delete()
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
TreeNode node = _tree.SelectedNode;
DirectoryInfo dirObj = GetDirObj(node);
dirObj.Delete(true);//删除文件夹、其子文件夹与文件
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this.DeleteSelectedNode();
this.FileLstCtl.Clear();
}
#endregion
/**/
/// <summary>
/// 删除选中的节点
/// </summary>
private
void
DeleteSelectedNode()
![ExpandedBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
{
try
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
_tree.Nodes.Remove(_tree.SelectedNode);
_tree.SelectedNode = null;
}
catch
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{}
}
2)
/***删除***/
#region/***删除***/
//删除
private void menuItem3_Click(object sender, System.EventArgs e)
![ExpandedSubBlockStart.gif](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);
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
if(result==DialogResult.Yes)
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
if(FoloderControl.DirectDel(path))
![ExpandedSubBlockStart.gif](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
转载于:https://www.cnblogs.com/flashicp/archive/2007/04/25/726911.html