Results 1 to 5 of 5

Thread: [RESOLVED] Reading a folder

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2005
    Posts
    294

    Resolved [RESOLVED] Reading a folder

    How would I read all sub folders of a folder, and then all files in the sub folders?

  2. #2
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: Reading a folder

    Here is a thread about that:
    LINK

    You'll just need to remove all Filename related stuff from that, cause you don't want to search, you want to list everything.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2005
    Posts
    294

    Re: Reading a folder

    VB Code:
    1. Public Function ReadFolder(Folder As String) As Object
    2.     ReadFolder = CreateObject("Scripting.FileSystemObject").GetFolder(Folder).Subfolders
    3. End Function
    Run-timer error '91': Object variable or With block variable not set

  4. #4
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: Reading a folder

    What's that? You did that? thats not from the code in the thread.

    You can't create and object and access its methods at the same time.

    Try
    VB Code:
    1. Dim fso as Object, f as Object, FolderName as String
    2.  
    3.     FolderName = App.Path & "\SomeDir"
    4.     Set fso = CreateObject("Scripting.FileSystemObject")
    5.     Set f = fso.GetFolder(FolderName)

    PS: Don't use the CreateObject stuff now, you will add it at the end.
    Now add the reference to Microsoft Scripting Runtime, and declare it like this:
    VB Code:
    1. Dim Fso    As Scripting.FileSystemObject
    And Instanciate like this:
    VB Code:
    1. Set fso = New Scripting.FileSystemObject
    Last edited by jcis; Dec 23rd, 2005 at 07:30 AM.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2005
    Posts
    294

    Re: Reading a folder

    I thought vb would have parsed it as
    VB Code:
    1. Public Function ReadFolder(Folder As String) As Object
    2.     ReadFolder = CreateObject("Scripting.FileSystemObject")
    3.     ReadFolder = ReadFolder.GetFolder(Folder).Subfolders
    4.     ReadFolder = ReadFolder.Subfolders
    5. End Function
    :/ oh well. Thanks for the help. Got it workin.

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