Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dowhile file doesnt exist

Status
Not open for further replies.

jonis2144

Programmer
Joined
Apr 26, 2002
Messages
7
Location
CA
hey all I cant seem to get this code to work. Im trying to make my program wait for my shell to finish ( i shell winzip and it creates a zip file) So i need the program to wait until it creates the actual file.
Heres what i got

Code:
ZipName = frmOptions.txtZipTo.Text
        Do While Dir(ZipName) = ""
        DoEvents
        Wait
    Loop


Why wont this work?
 
Code:
Private Function WaitForFileCreation(Filename As String, Optional Timeout As Long = 60) As Boolean
Dim StartTime As Date
StartTime = Now()
Do While (Dir(Filename) = &quot;&quot;) And (DateDiff(&quot;s&quot;, StartTime, Now()) < Timeout)
    DoEvents
Loop
WaitForFileCreation = (Dir(Filename) <> &quot;&quot;)
End Function

Private Sub Command1_Click()
If WaitForFileCreation(&quot;C:\wait.txt&quot;, 20) Then
    MsgBox &quot;File Created&quot;
Else
    MsgBox &quot;Timeout occurred&quot;
End If
End Sub

... works for me.

For code to wait until the shelled application has finished see faq222-428
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top