Sure. Use an application variable.
Code:
if Application("FILELOCKED")<>"true" then
Application("FILELOCKED")="true"
'do stuff with the file
Application("FILELOCKED")="false"
end if
To make it wait for the lock, instead of IF...THEN, use DO...LOOP.
If you're going to have a lot of connections to your site, you need to make sure two people don't execute the filelock check at the same time, because both would show it was unlocked then both would try to lock it. To do that, you'll have to use Application.Lock.
More Information:
- Instantly locks or hides any file using a password with a click
- That's all fine until one needs to write to the file which could get shot down while the lock is still active
- There musn´t be concurrent accesses to the file to prevent write problems
- Developers should not consider mandatory file locking as a security feature
- Once a file is locked, or hidden, it cannot be read or used by anyone until it is unlocked or shown
- Kill sFileName End If iFileHandle = FileLock(sFileName, eOpenUpdate, Len(tUser)) 'Open the file and lock it 'Add 10 users (all called Red!)
- This shareware allows you to encrypt/lock, decrypt/unlock files and folders, based on your needs
- 4 posts - 2 authors - Last post: Aug 29, 2003File Locking Issues - Microsoft Windows 2000 Setup
Bookmarks