File Locking in VBScript?!

Results 1 to 2 of 2

Thread: File Locking in VBScript?!

  1. #1
    Join Date
    Dec 1969

    Default File Locking in VBScript?!

    Hi guys,<BR><BR>I&#039;m creating a web-based application which will use log files to store certain information. The application is designed to be database-independant.<BR><BR>However, when building the application, I have ran into a slight "problem". I can&#039;t seem to find any information on file locking using VBScript.<BR><BR>Obviously, I don&#039;t want the following to happen:<BR>===== log.txt<BR>Message is: <BR>===== end log.txt<BR>1) Person A reads log.txt, and gets "Message is:"<BR>2) Person B reads log.txt, and gets "Message is:"<BR>3) Person A appends " Hello" and saves.<BR>4) Log.txt now contains "Message is: Hello"<BR>5) Person B appends " World" and saves.<BR>6) Log.txt now contains "Message is: World"<BR><BR>Obviously, the result I really want is "Message is: Hello World"!<BR><BR>When you open a file using the FileSystemObject, you specify the IOMODE (reading/writing/appending). Does this mean that VBScript has file-locking built in to that method?<BR><BR>I have also seen many people use Application.Lock, but according to all sources I can find, Application.Lock will lock the application scope - specifically, it will lock variables, properties, objects etc stored in the Application object, but I&#039;m not using the Application object to store any information!<BR><BR>Anyone got any ideas, because this is really starting to bug me!<BR><BR>Thanks,<BR><BR>Craig.

  2. #2
    Join Date
    Dec 1969

    Default RE: File Locking in VBScript?!

    hhhmmmm... I believe that when you open a file with FSO, it get&#039;s locked... And when you close it, it unlocks... You&#039;re right, Application.Lock will not help here...<BR><BR>Another way you could do this would be using Messege Queue... MSMQ....

Posting Permissions

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