Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
If a file exists
Message
De
16/03/2005 04:59:52
Neil Mc Donald
Cencom Systems P/L
The Sun, Australie
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00996204
Message ID:
00996208
Vues:
14
Hi,
>Does anybody know how I can check programmatically if a file exists in a certain location. I have a path and file stored to a variable and i want to check if it exists. For example:
>
>C:\program files\pictures\dress.tif
>
>If this file exists in this location I want to issue a messagebox command.
>
>Any help would be greatly appreciated.

Use FOPEN, the following example is from the help section

IF FILE('errors.txt') && Does file exist?
gnErrFile = FOPEN('errors.txt',12) && If so, open read/write
ELSE
gnErrFile = FCREATE('errors.txt') && If not, create it
ENDIF
IF gnErrFile < 0 && Check for error opening file
WAIT 'Cannot open or create output file' WINDOW NOWAIT
ELSE && If no error, write to file
=FWRITE(gnErrFile, 'Error information to be written here')
ENDIF
=FCLOSE(gnErrFile) && Close file
MODIFY FILE errors.txt NOWAIT && Open file in edit window
Regards N Mc Donald
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform