Is it possible to 'lock' a text file?

Results 1 to 2 of 2

Thread: Is it possible to 'lock' a text file?

  1. #1
    ASP Doofus Guest

    Default Is it possible to 'lock' a text file?

    My application reads user id&#039;s from a text file to determine users&#039; permissions. I&#039;ve created an admin. tool to allow administrators to add and delete users, and I&#039;m mildly concerned about two administrators overwriting each other&#039;s work. Is there any practical way to prevent that from happening. <BR><BR>Thanks in advance for any advice.

  2. #2
    Join Date
    Dec 1969

    Default RE: Is it possible to 'lock' a text file

    no simple way. you could take a hint from M$ and &#039;copy&#039; MS Access&#039;s locking mechanism - it simply writes a file to the same directory with the extension .ldb instead of .mdb - if the file exists, the DB is locked. you could use .lxt (!) you&#039;d have to write code to do the folowing<BR><BR>on open - check if lockfile exists, grant or deny access. if granted, write the lockfile (maybe write the administrator&#039;s name into it?)<BR>on close - delete the lockfile<BR><BR>the trouble i can see with this is, it&#039;s possible you may end up with files locked which you don&#039;t want locked if the user fails to unlock them, or the app somehow misses an unlock operation. perhaps you could write a master &#039;lock/unlock&#039; script. try it out though, i&#039;d be interested to see how you get on - email me through the site below if it works. I wouldn&#039;t mind publishing an article on it if it&#039;s successful.<BR><BR>j<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts