Code Bank
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingCode Bank

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old November 10th, 2005, 02:42 PM
sevenhalo sevenhalo is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2005
Location: Canto 34
Posts: 35 sevenhalo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 41 m 47 sec
Reputation Power: 3
VB.Net: FileSystem Directory Tree Constructor

This is a quick snippet that will populate a string array based on a parent directory with all of it's child directories (no matter how deep they are in the file system structure).

strPath is the directory for the parent
Code:
        Dim arrstrHold() As String
        Dim repeater As Integer = 0
        Dim dynamicCount As Integer = 0

        arrstrHold = IO.Directory.GetDirectories(strPath)
        dynamicCount = arrstrHold.Length
        Do While (repeater < dynamicCount)            
            If IO.Directory.GetDirectories(arrstrHold(repeater)).  Length > 0 Then
                ReDim Preserve arrstrHold(UBound(arrstrHold) + IO.Directory.GetDirectories(arrstrHold(repeater)).  Length)
                IO.Directory.GetDirectories(arrstrHold(repeater)).  CopyTo(arrstrHold, arrstrHold.IndexOf(arrstrHold, Nothing))
                dynamicCount += IO.Directory.GetDirectories(arrstrHold(repeater)).  Length
            End If
            repeater += 1
        Loop

It assumes that all the child directories of the parent have atleast read access. I am attempting to find a way around this without using exceptions. Until then, you can place a try/catch around "If IO.Directory.GetDirectories(arrstrHold(repeater)). Length > 0" and it will work fine for now.

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingCode Bank > VB.Net: FileSystem Directory Tree Constructor


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT