I am creating an application which uploads files into a database. One of the features is the ability to 'look inside' any compressed (zip) files on the database.

The code copies the zip file from the database to a temp directory. It then executes wzunzip in a command-line window on the zip file, with flags to create a text file containing a list of the compressed files.

The next part of the code test for the existence of the text file, with the FileExists method in the FileSystemObject. Although the text file exists (I can see it in the directory), the FileExists call returns false!

Is this a timing issue? The file clearly exists; however, since all of the code is executing in the same subroutine, perhaps VB is executing the code out or order (for efficiency purposes) and this is why the FileExists call doesn't "see" the newly created file?

How can I ensure that the FileExists call occurs in real-time after the creation of the txt file?

Here's some of my code:

Dim fso as object
Set fso = CreateObject("Scripting.FileSystemObject")

' copies a zip file from the database to a temporary directory
CopyFileStream oRS, TempDir, CStr(aQueue(j, 2)), "FileValue", False

' executes "wzunzip" on command-line on zip file, with flags to export a list of the compressed files to a new text file
CreateCompressedFilesList gsTempDir & "\" & CStr(aQueue(j, 2)), TempDir & "\" & csListFile

' time delay subroutine
TimeDelay 100000000

' if text file exists, process file, else return error
If (fso.FileExists(TempDir & "\" & csListFile)) Then
Set fso = Nothing
aQueue(j, ciZipListColumn) = ReadFileIntoArray(TempDir & "\" & csListFile)
Else
Err.Raise 1000, "CQ", TempDir & "\" & csListFile & " does not exist."
End If

The main part of the code in CreateCompressedFilesList is as follows:

sCmd = "wzunzip " & Chr(34) & sZipFile & Chr(34) & " -@" & Chr(34) & sListFile & Chr(34)
Set wsh = CreateObject("WScript.Shell")
Set oExec = wsh.exec(sCmd)
Set oExec = Nothing
Set wsh = Nothing