Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Lock and unlock a file
Message
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Lock and unlock a file
Divers
Thread ID:
01638353
Message ID:
01638353
Vues:
81
Hi,

I was wondering if anybody would point potential problems with the following approach of locking and unlocking a file:
*-- Lock file
nHandle = fopen( 'MyFile', 0 )

if nHandle < -1
   *-- File not locked
endif 

*-- The code "nHandle = fopen( 'MyFile', 0 )" will return -1 for
*-- any other user on another PC.  Correct?

*-- Unlock file
if nHandle > 0
   fclose( nHandle )
endif  
I want also to be sure that if the user shuts down his/her computer, the lock on the file 'MyFile' is released.

TIA
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform