-
Jun 4th, 2013, 07:02 AM
#1
Thread Starter
Junior Member
FileSystemObject and SubFolders
Hello guys,
I am trying to create an updater in vb6 using CRC32 checksums. I have got the checksum creation code but I don't know how to go into a file directory and get the path of the file. I am using the FSO for this.
This is what I mean:
There is a main folder. (This is the root folder.)
There are subfolders within the main folder.
There might be subfolders within the first subfolders.
I want to go through the all the folders and subfolders from the main folder. How would I go around doing this. I have some code, but it won't work.
Thanks
Abhi2011
-
Jun 4th, 2013, 07:10 AM
#2
Re: FileSystemObject and SubFolders
Are you simply trying to return the full path to a particular file? If so, then try the SearchTreeForFile API. Here is an example
vb Code:
Private Declare Function SearchTreeForFile Lib "imagehlp" _
(ByVal RootPath As String, ByVal InputPathName As String, _
ByVal OutputPathBuffer As String) As Long
Private Const MAX_PATH = 260
Private Sub Command1_Click()
Dim tempStr As String, Ret As Long
'create a buffer string
tempStr = String(MAX_PATH, 0)
'returns 1 when successfull, 0 when failed
Ret = SearchTreeForFile("c:\", "winword.exe", tempStr)
If Ret <> 0 Then
MsgBox "File located in " + Left$(tempStr, InStr(1, tempStr, Chr$(0)) - 1)
Else
MsgBox "File not found!"
End If
End Sub
-
Jun 4th, 2013, 07:12 AM
#3
Thread Starter
Junior Member
Re: FileSystemObject and SubFolders
I am not trying to find a specific file. I just want to return all the paths of files from a tree. I don't know their name.
-
Jun 4th, 2013, 07:14 AM
#4
Re: FileSystemObject and SubFolders
Basically you want to programmatically create a Windows Explorer then, right?
Thats going to take some pretty serious recursion.
How about using a Common Dialog control?
-
Jun 4th, 2013, 07:16 AM
#5
Thread Starter
Junior Member
Re: FileSystemObject and SubFolders
No. I want to get the paths of the files from a main folder with the help of a folder tree.
-
Jun 4th, 2013, 09:13 AM
#6
Re: FileSystemObject and SubFolders
There are lots of reasons to avoid using the FSO and either use the intrinsic Dir$() function or API calls, performance being the main one. The only real advantage of API calls over Dir$() is when you need to handle Unicode names.
Have you looked at DirLister lightweight Dir() wrapper?
This gives you drop-in class modules that make using Dir$() easy even when you need to traverse trees of directories. As a bonus it avoids the need to use recursion, something that plagues most Dir$()-based examples.
Hopefully you aren't using the FSO's I/O to do anything with CRCs. The FSO only supports text-mode file processing, which scrambles binary information.
-
Jun 4th, 2013, 10:54 AM
#7
Thread Starter
Junior Member
Re: FileSystemObject and SubFolders
Thanks for the link. I'll look into it. And know I am not doing anything with FSO I/O for CRCs. Just for traversing the tree and getting the paths of files within the tree.
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
|