943,840 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 471
  • VB.NET RSS
Aug 28th, 2009
0

Display System Directory

Expand Post »
I am wanting to display the PC's System Directory in a treeview. I have been searching for how to do this for some time now without finding anything. if anybody can help me out i would greatly appreciate it.

thanks
Similar Threads
Reputation Points: 31
Solved Threads: 29
Posting Whiz in Training
ProfessorPC is offline Offline
270 posts
since Dec 2007
Aug 28th, 2009
1

Re: Display System Directory

try this:
vb Syntax (Toggle Plain Text)
  1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  2. treeDir.Nodes.Clear()
  3. CreateDirTree(Nothing, Environment.SystemDirectory)
  4. End Sub
  5.  
  6. Private Sub CreateDirTree(ByVal fromNode As TreeNode, ByVal basePath As String)
  7. Dim newDir As TreeNode
  8. Dim subDir As String
  9.  
  10. For Each singleDir As String In My.Computer.FileSystem.GetDirectories(basePath)
  11. subDir = My.Computer.FileSystem.GetName(singleDir)
  12.  
  13.  
  14. If fromNode Is Nothing Then
  15. newDir = treeDir.Nodes.Add(subDir)
  16. Else
  17. newDir = fromNode.Nodes.Add(subDir)
  18. End If
  19.  
  20. CreateDirTree(newDir, My.Computer.FileSystem.CombinePath(basePath, subDir))
  21. Next singleDir
  22. End Sub
Featured Poster
Reputation Points: 208
Solved Threads: 168
Practically a Master Poster
GeekByChoiCe is offline Offline
692 posts
since Jun 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: Searching for a Solutions Manual
Next Thread in VB.NET Forum Timeline: tokenize text input





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC