Results 1 to 7 of 7

Thread: using FileSystemObject to get subfolders

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Posts
    106

    using FileSystemObject to get subfolders

    Hi
    I'm using this code to get subfolders but i got them arranged by modify time
    How can i make them arrange by name
    "Changing folder sort type form windows explorer makes no change"


    VB Code:
    1. Dim FS As New FileSystemObject
    2.     Dim FSfolder As Folder
    3.     Dim subfolder As Folder
    4.     Dim i As Integer
    5.    
    6.     Set FSfolder = FS.GetFolder(progpath + "data\")
    7.    
    8.     ReDim installed(FSfolder.SubFolders.Count - 1)
    9.    
    10.     i = 0
    11.     For Each subfolder In FSfolder.SubFolders
    12.         DoEvents
    13.         installed(i) = subfolder.Name
    14.         i = i + 1
    15.     Next subfolder
    16.     Set FSfolder = Nothing

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: using FileSystemObject to get subfolders

    Quote Originally Posted by Tnen
    ... How can i make them arrange by name
    "Changing folder sort type form windows explorer makes no change" ...
    That's because "actual" sort order is unknown - remember, Windows Explorer is an application so it was programmed to do things but you're getting list of folders/subfolders/files directly from system and god knows how they are all arranged.
    What I may suggest is to use Listview control so you can load names/dates/etc so you can sort on a column you wish.

  3. #3
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: using FileSystemObject to get subfolders

    Being sorted by date modified is logical - that's probably how the file system works. Not that I have any intimate knowledge of it.

    Quote Originally Posted by RhinoBull
    What I may suggest is to sue Listview control
    I thought of that once, but the legal fees put me off

  4. #4
    Fanatic Member kaffenils's Avatar
    Join Date
    Apr 2004
    Location
    Norway
    Posts
    946

    Re: using FileSystemObject to get subfolders

    Why don't you just sort the array installed() when all sub folders are loaded into it.

  5. #5

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Posts
    106

    Re: using FileSystemObject to get subfolders

    thanks for replies but
    how to
    Why don't you just sort the array installed() when all sub folders are loaded into it.

  7. #7
    Fanatic Member kaffenils's Avatar
    Join Date
    Apr 2004
    Location
    Norway
    Posts
    946

    Re: using FileSystemObject to get subfolders

    Quote Originally Posted by Tnen
    thanks for replies but
    how to
    You can use bubble sorting.

    http://iweb.tntech.edu/bhuguenard/ds3850/bubbleSort.htm

    This example uses an integer array, but it works just as good with a string array.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width