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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File In Use? 1

Status
Not open for further replies.

zzfive03

Programmer
Jun 11, 2001
267
I am using VB 6.0 I have a loop that creates PDF files.

After the file is created with Distiler, I move it to a location on the hard drive. The problem I have is when I use FSO, I check with FSO.FileExists() But just because the file exists, does not mean it is finished being built. I usualy get a "permission denied" error.

Is there an API call I can do before I preform work on the file that can tell if the file is in use?

Example:

BuildPDF("C:\temp.pdf") ' (existing func)

WaitForFileToBecomeNotInUse("C:\temp.pdf") ' (ideal func)
' - - continue with my process

Any help on this would be great.
THank you, Mark


 
Try this function:

Public Function IsOpen(strFileName As String) As Boolean
Dim FileNum As Long
On Error GoTo OpenError
FileNum = FreeFile
Open strFileName For Input Lock Read Write As FileNum
Close FileNum
Exit Function
OpenError:
IsOpen = True
End Function
 
Thanks a lot, I think that will work nicely.

--Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top