Tree view delete
-
Hi, i have a folder view which list all my folders in a tree view form. My requirement is, after selecting a folder if i send a delete command it has to delete all folders and its contents. Problem is only after deleting the files in the subfolders,i can delete the folder. i need to do an recursive search. Urgent.... plzzzzzzzz reply. I am using c# windows application. e.g 1 11 12 121 122 13 say my tree view looks like this... if i delete the folder 1. it should find out all the subfolders. Should delete 13 first and 122 and then 121 and 12 and 11. plzzzzzzz do guide me... Thanks in advance...:((
-
Hi, i have a folder view which list all my folders in a tree view form. My requirement is, after selecting a folder if i send a delete command it has to delete all folders and its contents. Problem is only after deleting the files in the subfolders,i can delete the folder. i need to do an recursive search. Urgent.... plzzzzzzzz reply. I am using c# windows application. e.g 1 11 12 121 122 13 say my tree view looks like this... if i delete the folder 1. it should find out all the subfolders. Should delete 13 first and 122 and then 121 and 12 and 11. plzzzzzzz do guide me... Thanks in advance...:((
private void DeleteStuff(TreeNode root) {
// If you have children, process them first
foreach (TreeNode tn in root.Nodes) {
DeleteStuff(tn);
}
// Delete files
}
Try code model generation tools at BoneSoft.com.
-
private void DeleteStuff(TreeNode root) {
// If you have children, process them first
foreach (TreeNode tn in root.Nodes) {
DeleteStuff(tn);
}
// Delete files
}
Try code model generation tools at BoneSoft.com.
:doh:hi i did but then its not working properly..... if i select a node. the rootnode.nodes property is not taking the subfolders of the child node.... 1 11 12 13 131 132 14 in the above the 131 and 132 nodes are not accecible.... they r not coming under the collectios..... plzzzzzzzz help me.. thanks a lot in advance......cheers.
-
:doh:hi i did but then its not working properly..... if i select a node. the rootnode.nodes property is not taking the subfolders of the child node.... 1 11 12 13 131 132 14 in the above the 131 and 132 nodes are not accecible.... they r not coming under the collectios..... plzzzzzzzz help me.. thanks a lot in advance......cheers.
If you use the method above, and pass it node '13', it will process '131' and '132' before doing 13. You're not using the
treeView.Nodes
are you? What ever owns the 1, 11, 12, 13 & 14 nodes (treeView or another node) won't have 131 and 132 in it'sNodes
collection, node 13 will. ATreeNode
object has aNodes
colleciton just asTreeView
does. That's why the method above accepts aTreeNode
, and pocesses it's children before itself. Maybe I don't fully understand you question.
Try code model generation tools at BoneSoft.com.