|
-
Dec 23rd, 2005, 05:30 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Reading a folder
How would I read all sub folders of a folder, and then all files in the sub folders?
-
Dec 23rd, 2005, 05:50 AM
#2
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.
-
Dec 23rd, 2005, 07:08 AM
#3
Thread Starter
Hyperactive Member
Re: Reading a folder
VB Code:
Public Function ReadFolder(Folder As String) As Object
ReadFolder = CreateObject("Scripting.FileSystemObject").GetFolder(Folder).Subfolders
End Function
Run-timer error '91': Object variable or With block variable not set
-
Dec 23rd, 2005, 07:20 AM
#4
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:
Dim fso as Object, f as Object, FolderName as String
FolderName = App.Path & "\SomeDir"
Set fso = CreateObject("Scripting.FileSystemObject")
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:
Dim Fso As Scripting.FileSystemObject
And Instanciate like this:
VB Code:
Set fso = New Scripting.FileSystemObject
Last edited by jcis; Dec 23rd, 2005 at 07:30 AM.
-
Dec 23rd, 2005, 07:41 AM
#5
Thread Starter
Hyperactive Member
Re: Reading a folder
I thought vb would have parsed it as
VB Code:
Public Function ReadFolder(Folder As String) As Object
ReadFolder = CreateObject("Scripting.FileSystemObject")
ReadFolder = ReadFolder.GetFolder(Folder).Subfolders
ReadFolder = ReadFolder.Subfolders
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|