Results 1 to 4 of 4

Thread: FSO Question

  1. #1

    Thread Starter
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657
    I'm working on an app which in some cases creates subfolders below "App.Path" (got that part working fine) and in some cases I want to go through and delete all such subfolders (each subfolder is named with a specific pattern). The second part is where I'm stuck. I would like to use the FSO; I've used it a little bit and would like to use it more. I envision the pseudocode for this thing as something like the following:
    Code:
    'pseudocode:
    
    For Each Subfolder In (App.Path)
        If Subfolder.Name Like "MyPattern" Then
            fso.DeleteFolder Subfolder.Name
        End If
    Next
    Can someone help and substitute the pseudocode with the proper VB syntax? I would be eternally grateful ...
    "It's cold gin time again ..."

    Check out my website here.

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    'this will kill all sub folders in C:\My Documents
    
    Option Explicit
    
    
    Sub ShowFolderList(folderspec)
    
        Dim fs, f, f1, s, sf
        Set fs = CreateObject("Scripting.FileSystemObject")
        Set f = fs.GetFolder(folderspec)
        Set sf = f.SubFolders
        For Each f1 In sf
            s = f1.Name
    
            fs.Deletefolder (folderspec & "\" & s)
            s = s & vbCrLf
        Next
       
    End Sub
    
    
    Private Sub Image1_Click()
        Call ShowFolderList("C:\my documents")
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3

    Thread Starter
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657
    Thanks Wayne, I appreciate the help. If you don't mind, here's a follow-up question. I know that in VBScript, all variables are variant, but in straight VB, what would you DIM these variables as? I know that "f" and "f1" would have to be "Folder", but how about "sf"?
    "It's cold gin time again ..."

    Check out my website here.

  4. #4
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946
    dim fs as object
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

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