Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to tell if a text file is open by another process.
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00220819
Message ID:
00221035
Views:
56
>>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
thanks to all -- current job has managed to flush all knowledge from what was left of my brain. i'll try these and let you know what happens...
Previous
Reply
Map
View

Click here to load this message in the networking platform