>we pull text files into tables for processing nightly. The text files are downloaded by FTP from various machines. We need to be able to tell when the text files are closed by this process, because our processing can't work on these files until they are completely downloaded.
>
>any ideas?
It's pretty trivial, actually; simply try opening the file using low-level file I/O for R/W access using FOPEN(); if it fails, something else is using it, or you don't have the necessary permissions to access it:
FUNCTION CanIUseFile
LPARAMETER tcFileName
IF TYPE('tcFileName') # 'C' OR ! FILE(tcFileName)
RETURN .F.
ENDIF
LOCAL nFH
nFH=FOPEN(tcFileName,2)
IF nFH # -1
=FCLOSE(nFH)
RETURN .T.
ELSE
RETURN .F.
ENDIF