Just to start this off right, thanks for any help.
I have a database that has network locations to documents stored as \\networkresour ceblah\document s\file.pdf in a text field.
After the user is done and presses a button. Here are the actions that it goes through after that.
The problem I am running in to is...if the file is large then the file name exists before the document is finished building itself. When the database sees the document name, even if it is only 0 kb, then it copies it at that point and deletes the original. I have placed this code to wait, but it doesn't always work, since the code is finite, and has a point that it quits waiting.
As you can see, I look for the file in the temp directory, wait 5 seconds, copy it across, wait 1 second, look for the new file in the new location, then delete the originals. This feels like an eternity sometimes. Is there a way to determine if a file is in use or "being built", prior to copying it. That would allow me to drastically reduce time to the user.
I have a database that has network locations to documents stored as \\networkresour ceblah\document s\file.pdf in a text field.
After the user is done and presses a button. Here are the actions that it goes through after that.
- Copies files from the network location to a temp folder on their computer.
- Uses pdftk to join all of the documents together and name the new document (in the temp folder)
- Looks for the new document to exist in the temp folder
- Copies the file to a new location
- Verifies that the named document is in the new location
- Deletes all of the files in the temporary location.
The problem I am running in to is...if the file is large then the file name exists before the document is finished building itself. When the database sees the document name, even if it is only 0 kb, then it copies it at that point and deletes the original. I have placed this code to wait, but it doesn't always work, since the code is finite, and has a point that it quits waiting.
Code:
StartTimer:
If fso.FileExists(SPath & FileName) Then
Wait = Timer
While Timer < Wait + 5
DoEvents
Wend
fso.CopyFile (SPath & FileName), NPath, True
fso.CopyFile (SPath & FileName), DPath, True
Else
GoTo StartTimer
End If
Wait = Timer
While Timer < Wait + 1
DoEvents
Wend
StartSecondTimer:
If fso.FileExists(DPath & FileName) Then
Kill SPath & "*.*"
Else
Wait = Timer
While Timer < Wait + 1
DoEvents
Wend
GoTo StartSecondTimer
End If
Comment