To get the names of folders and sub folders 
Author Message
 To get the names of folders and sub folders

To All

I am trying to find a function that will get the names of all folders within
another folder and then store them in an array.
I thought i had done this until the amount of folders became too many.
It then cause a stack overflow.
If any body has a ready made function that i could put in a .bas module

ie

Public Function GetDirs(StartFolder as String)
Dim fCount as Integer
Do Until EOF
*****************************************
'This is the code i need here
Put Dir names into FolderNameArray(fCount)
****************************************
fCount = fCount + 1
Loop

End Function

As you can tell this would not work,so if anyone can help.Please.

Many Thanks

Garry



Fri, 07 Nov 2003 02:50:23 GMT  
 To get the names of folders and sub folders
'Check this for typos, I have typed it in the newsreader, not VB, you'l need
to add a reference to teh Scripting Runtime Library, mscrunn.dll (or
something like that)
'Stick this in a function that returns an array of strings

Dim ofsoFileSystem as New Scripting.Filesystemobject
Dim ofsoFolder as Scripting.Folder
Dim sarSubFolderNames() as String
Dim ofsoSubFolder as Scripting.Folder
Dim lFolderCount as Long

Set ofsoFolder = ofsoFileSystem.GetFolder("C:\Sample Folder")
If ofsoFolder.SubFolders.Count > 0 Then
    lFolderCount  = 1
    Redim sarSubFolderNames(1 to ofsoFolder.SubFolders.Count)
    For Each  ofsoSubFolder In ofsoFolder.SubFolders
        sarSubFolderNames(lFolderCount) = ofsoSubFolder.Name
        lFolderCount = lFolderCount +1
    Next
End if
set ofsoSubFolder =Nothing
set ofsoFolder=Nothing
set ofsoFileSystem =Nothing


Quote:
> To All

> I am trying to find a function that will get the names of all folders
within
> another folder and then store them in an array.
> I thought i had done this until the amount of folders became too many.
> It then cause a stack overflow.
> If any body has a ready made function that i could put in a .bas module

> ie

> Public Function GetDirs(StartFolder as String)
> Dim fCount as Integer
> Do Until EOF
> *****************************************
> 'This is the code i need here
> Put Dir names into FolderNameArray(fCount)
> ****************************************
> fCount = fCount + 1
> Loop

> End Function

> As you can tell this would not work,so if anyone can help.Please.

> Many Thanks

> Garry



Fri, 07 Nov 2003 16:53:38 GMT  
 To get the names of folders and sub folders

Quote:

> To All

> I am trying to find a function that will get the names of all folders within
> another folder and then store them in an array.
> I thought i had done this until the amount of folders became too many.
> It then cause a stack overflow.
> If any body has a ready made function that i could put in a .bas module

What does the code you're using now look like? Does the array have to be
in any particular order? If you're running out of stack, there might be
too many folders to store in an array, and you'll need to use some other
data structure instead.

--

WARNING: I cannot be held responsible for the above        They're   coming  to
because  my cats have  apparently  learned to type.        take me away, ha ha!



Sat, 08 Nov 2003 01:19:19 GMT  
 To get the names of folders and sub folders
Store the Folder/File names in a Text file

You can sort it with: www.iss.u-net.com/dsortv.htm

Look at using the FindFirstFile/FindNextFile APIs

On Sun, 20 May 2001 19:50:23 +0100, "Garry Martin"

Quote:

>To All

>I am trying to find a function that will get the names of all folders within
>another folder and then store them in an array.
>I thought i had done this until the amount of folders became too many.
>It then cause a stack overflow.
>If any body has a ready made function that i could put in a .bas module

>ie

>Public Function GetDirs(StartFolder as String)
>Dim fCount as Integer
>Do Until EOF
>*****************************************
>'This is the code i need here
>Put Dir names into FolderNameArray(fCount)
>****************************************
>fCount = fCount + 1
>Loop

>End Function

>As you can tell this would not work,so if anyone can help.Please.

>Many Thanks

>Garry



Sat, 08 Nov 2003 16:48:23 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Find Sub Folder Name within a Folder

2. Build XML of folders, sub folders and files from specified folder

3. Enumerate a Folder and it's Sub Folders

4. Deleting certian Files in Folders and there sub folders

5. Copy the files and sub folders to another folder

6. Getting Sub Folder Access

7. Returning all file names from given folder directory and all sub-directories

8. Getting name of machine connected to a shared folder

9. Problem with getting folder names from Network DFS

10. folder in a folder in a folder...

11. Determining if a folder is a local pst folder or a imap (server folder)

12. How to delete folders/files within a folder but not the folder itself

 

 
Powered by phpBB® Forum Software