Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to tell if a text file is open by another process.
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00220819
Message ID:
00220940
Vues:
24
>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
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform