Can you lock a text file like a database?

Results 1 to 2 of 2

Thread: Can you lock a text file like a database?

  1. #1
    Join Date
    Dec 1969

    Default Can you lock a text file like a database?

    I have a form and the last thing it does is write a bit of information to a text file. In testing, I do not have any problems in doing this. However, I have a concern that if multiple users hit submit at the same time, what will happen to the text file. Does it "lock" itself for each write, or will my data be screwed up, or will I miss some of the submits. Before going live, I&#039;d be curious if anyone knows if a text file can be locked for each write so I don&#039;t miss any data?<BR><BR>Thanks...<BR><BR>Here&#039;s the last bit of code:<BR><BR>Const ForAppending = 8<BR>Dim objOpenFile, objFSO, strPath<BR>strPath = Server.MapPath("/reports/report.asp")<BR>Set objFSO = Server.CreateObject("Scripting.FileSystemObject")< BR>If objFSO.FileExists(strPath) Then<BR>Set objOpenFile = objFSO.OpenTextFile(strPath, ForAppending)<BR>Else<BR>Set objOpenFile = objFSO.createTextFile(strPath)<BR>End if<BR>objOpenFile.WriteLine(" " & strmysess & " " & strempfstname & " " & stremplstname & " &#060;br /&#062; ")<BR>objOpenFile.Close<BR>Set objOpenFile = Nothing<BR>Set objFSO = Nothing

  2. #2
    Join Date
    Dec 1969
    Los Angeles, CA

    Default With a hack sure

    create an application variable. <BR><BR>say <BR>Application("FileLock") = "off"<BR><BR>when you are editing the file set the app variable to "on" and after you are done set it back to "off"<BR><BR>only allow a user to edit the file if the app variable is "off"<BR><BR><BR><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