Problem with append mode when using FileOpen

Discussion in 'Questions (Windows Mobile)' started by bluedude, Jul 27, 2009.

  1. bluedude

    bluedude Well-Known Member Licensed 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)
     
  2. specci48

    specci48 Well-Known Member Licensed User

    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
     
  3. bluedude

    bluedude Well-Known Member Licensed User

    Thanks!

    Thanks,

    It was a long night :)
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice