any method to do this in an extrememly fast way ?
with no impact on a user waiting for it to fill?
Printable View
any method to do this in an extrememly fast way ?
with no impact on a user waiting for it to fill?
You might need to do that on different thread than the UI Thread .
A quick demo . If you have any questions , post here .
VB Code:
Public Sub FILLTreeV(ByVal path As String) Dim FitN As TreeNode Dim DitN As TreeNode For Each file As String In IO.Directory.GetFiles(path) FitN = New TreeNode(file) Me.TreeView1.Nodes.Add(FitN) Next For Each dir As String In IO.Directory.GetDirectories(path) DitN = New TreeNode(dir) Me.TreeView1.Nodes.Add(DitN) FILLTreeV(dir) Next End Sub 'Use FILLTreeV("c:\data")
and also had a thought - what if i just populated all the directories -
i reworked your code to populate the tree with the directories only and that is fast ! and looks like the whole file structure is there - just what i want - but
then if a user clicks on the node to see the insides of the directory then i would populate that on the fly -
how would i do that? is there an event so i can fill in the files or (subdirectories) under the correct node of the tree?
That's easy I think . I'll give you the idea , if you still can't get it to work then let me know (I'm just little busy now) . Ok , use a counter that increments folders found then use this counter as index in the treenode index value . I remember I did it this way and worked well . Sorry as I said I can't give you the full code right now but if you're stuck , then I'll help you .
Just what I was looking for.