Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Mar 2001
    Location
    Oregon, USA
    Posts
    129
    Thanks
    0
    Thanked 0 Times in 0 Posts

    FileSystemObject woes

    Trying to get a simple loop to nuke files with a certain extension. The following code errors out with file not found on the "Set f" line even though the file is definitely there.

    Set fs = CreateObject("Scripting.FileSystemObject")

    With Application.FileSearch
    .FileName = "*.gid"
    .LookIn = strDevelPath
    .SearchSubFolders = True
    .Execute
    For i = 1 To .FoundFiles.Count
    Set f = fs.GetFile(fs.GetFileName(.FoundFiles(i)))
    If f.Attributes And 2 Then f.Attributes = f.Attributes - 2
    If f.Attributes And 1 Then f.Attributes = f.Attributes - 1
    Kill .FoundFiles(i)
    Next
    End With


    Thanks for any input,

    Chris

  2. #2
    3 Star Lounger
    Join Date
    Feb 2001
    Location
    NYC,USA,Earth
    Posts
    273
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: FileSystemObject woes

    Is there a name property for that object...?

    Set f = fs.GetFile(fs.GetFileName(.FoundFiles(i).Name))

  3. #3
    2 Star Lounger
    Join Date
    Mar 2001
    Location
    Oregon, USA
    Posts
    129
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: FileSystemObject woes

    Got it to work with:

    Set f = fs.GetFile(.FoundFiles(i).Name)

    Thanks,

    Chris

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •