Problem with append mode when using FileOpen

bluedude

Well-Known Member
Licensed User
Longtime User
What is wrong with below code. cAppend does not write anything.

DateFormat("dd-mm-yyyy")
sData=Date(Now) & Chr(9) & sData
DateFormat ("ddmmyy")
sFile=Date(Now) & ".txt"
If FileExist (AppPath & "\logs\" & sFile) = True Then
FileOpen (c1,sFile,cWrite,cAppend)
FileWrite (c1,sData)
Else
FileOpen (c1,AppPath & "\logs\" & sFile,cWrite)
FileWrite (c1,sData)
End If
'close the file
FileClose (c1)
 

specci48

Well-Known Member
Licensed User
Longtime User
What is wrong with below code. cAppend does not write anything.
The append works fine but I'm sure you missed the red statements in your code so that a new file was created (and updated !) in the AppPath instead in the subdirectory "logs":


DateFormat("dd-mm-yyyy")
sData=Date(Now) & Chr(9) & sData
DateFormat ("ddmmyy")
sFile=Date(Now) & ".txt"
If FileExist (AppPath & "\logs\" & sFile) = True Then
FileOpen (c1,AppPath & "\logs\" & sFile,cWrite,cAppend)
FileWrite (c1,sData)
Else
FileOpen (c1,AppPath & "\logs\" & sFile,cWrite)
FileWrite (c1,sData)
End If
'close the file
FileClose (c1)


specci48
 
Top