I am trying to log actions users take in my Web App and the append function doesn’t seem to be working. Here is the routine.
Dim t As TextOutputStream
Dim f As FolderItem
dim d as new Date
f = GetFolderItem(“userlog.txt”)
If f <> Nil Then
t = TextOutputStream.Append(f)
t.Write("Successful Login " + d.SQLDateTime + " ID = " + str(Lcid) + chr(13))
t.Close
End If
The file gets written, but it is always the first line, the next entry just replaces the first line again. No Append.
I have tried t.Write and t.WriteLine with no difference.
I just ran into this! You are creating the file alongside the debug app, so the file is deleted every time you run the app anew (I think). You can confirm my theory by temporarily using a different location like:
When you Run the project from the IDE, it creates a subfolder and builds the executable in the subfolder. That is where the file is being created. When you quit the debug session, the subfolder is removed along with all its contents, including your file. So every time you run from the IDE, it’s creating a brand new file, which is then deleted when you quit.