joethis said:
Is there a way to make sure that a file is already in use using asp?
For instance, if one person has opened a file and is about to write
to it; then is there a way to keep another user from reading, or
writing to that text file until the first user is finished?
Use a database. Doing this will severely impair the scalabiltiy of your
application because you will need to serialize this operation. One way to do
it is as follows:
User A renames the file. Opens it and starts updating. User B attempts to
open file, doesn't find it and waits. User A finishes edits saves, closes
and gives file its original name. User B renames it and opens it.
Or do you need to allow multiple users to have it open at the same time? You
might try a "semaphore" system:
User A creates an editlock file and opens the file for editing. Other users
can read the file, but no one else can create another editlock file until
User A is finished. When user A finishes editing the file, he deletes the
editlock file. If other users open a file which is locked for editing, set a
flag in a global variable indicating that the file needs to re-read before
they are allowed to lock it for editing. There are all sorts of gotchas that
can shoot this plan down, so you have to realize that you are attempting to
do the same thing a database management system does, i.e., you are
reinventing the wheel. Use a database.
Bob Barrows