Refresh Directory File List

  • Thread starter Thread starter Todd Lemen
  • Start date Start date
T

Todd Lemen

I have routine that uses the FileSystemObject to
determine the existance of a folder. If the folder is
found, I pass control to a function that uses a Scripting
Directory object to populate a list with the names of
subdirectories. If the folder is not found, it offers
the user a chance to create one. While it does so, it
creates several subfolders. When this routine finishes,
the procedure deconstructs the FileSystemObject (by
setting the FSO variable to Nothing) and passes control
to the aforementioned "populate the list" function.

Problem seems to be a file system refresh... When
control passes after creating the folder and subfolders,
I have to exit these routines entirely before the
Directory object can read the new folder's subfolders. Is
there a "refresh file system" command somewhere?
 
Why not scrap FSO, and use strictly VBA commands?

You can check for the existence of a folder using the Dir function:

strFolder = "C:\Temp"
If Len(Dir(strTemp, vbDirectory)) > 0 Then
' Folder exists
Else
' Folder doesn't exist
End If

You can create folders using the MkDir statement:

MkDir "C:\Temp"
MkDir "C:\Temp\SubDir"
 
That's odd: I've never encountered any such problems.

Are you creating the folders on a network share or on the workstation? What
does your code look like?
 
OK... I stepped through the code, and found my error. I
was passing the wrong directory name to my GetSubFolder
function. All is working.

Thanks again for your help, Doug!

TL
 
Back
Top