Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Checking to see if a file can be written to
Message
De
06/11/2002 15:51:40
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00719448
Message ID:
00719562
Vues:
16
DIMENSION aFiles[1]     && make sure array exists
ADIR(aFiles, tcFile)    && get the file into a 1 element array
llCanWrite = !Empty(aFl[1,1]) And Empty(CHRTRAN(aFl[1,5], 'A.', '')) && check attributes
Alan

>Does anyone have a better way to do this, than the function below?
>
>
>*********************
>FUNCTION CanWrite
>*********************
>PARAM tcFile
>LOCAL llCanWrite,lnHandle
>IF NOT FILE(tcFile)
> *File doesn't exist, so it can be created.
> llCanWrite = .t.
>ELSE
> *If the file does exist, try to open it as
> *read/write.
> lnHandle = FOPEN(tcFile,2)
> llCanWrite = (lnHandle > 0)
> *Make sure the file gets closed. This will
> *leave the file vulnerable to get opened by
> *another person in the meantime.
> FCLOSE(lnHandle)
>ENDIF
>RETURN llCanWrite
>
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform