Results 1 to 7 of 7

Thread: FileSystemObject and SubFolders

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2012
    Posts
    27

    Question 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

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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:
    1. Private Declare Function SearchTreeForFile Lib "imagehlp" _
    2. (ByVal RootPath As String, ByVal InputPathName As String, _
    3. ByVal OutputPathBuffer As String) As Long
    4.  
    5. Private Const MAX_PATH = 260
    6.  
    7. Private Sub Command1_Click()
    8.     Dim tempStr As String, Ret As Long
    9.     'create a buffer string
    10.     tempStr = String(MAX_PATH, 0)
    11.     'returns 1 when successfull, 0 when failed
    12.     Ret = SearchTreeForFile("c:\", "winword.exe", tempStr)
    13.     If Ret <> 0 Then
    14.         MsgBox "File located in " + Left$(tempStr, InStr(1, tempStr, Chr$(0)) - 1)
    15.     Else
    16.         MsgBox "File not found!"
    17.     End If
    18. End Sub

  3. #3

    Thread Starter
    Junior Member
    Join Date
    May 2012
    Posts
    27

    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.

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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?

  5. #5

    Thread Starter
    Junior Member
    Join Date
    May 2012
    Posts
    27

    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.

  6. #6
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    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.

  7. #7

    Thread Starter
    Junior Member
    Join Date
    May 2012
    Posts
    27

    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
  •  



Click Here to Expand Forum to Full Width