Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to lock a file with FSO

Status
Not open for further replies.

Fatbelly

Technical User
Jan 5, 2002
6
GB
Hi,

I'm using File Scripting Object to store the last used sequential number in a txt file. This file is used by many users, but i want to avoid that it's opened simultainiously by more than one user at the same time.
Therefore can somebody tell me how to lock a file, for other users, when it's being acessed by one of the users. The best solution should be that i can pop-up a message telling the file is currently being in use by another user.

Many thanks,
Fatbelly
 
How about write the name of the user who has the file open to the file too, that way you can determine if the file is being used by another user.

Alternatively you could use an ini file...

Andy
--
"Logic is invincible because in order to combat logic it is necessary to use logic." -- Pierre Boutroux
 
Locking a file is one of the areas of weakness of the FileSystemObject - it cannot do it. In this case you might be better off using VB's more traditional file i/o; the Open statement takes a Lock parameter
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top