FileSize(file) brings up error on device - but not on Desktop

Discussion in 'Questions (Windows Mobile)' started by TWELVE, May 9, 2008.

  1. TWELVE

    TWELVE Active Member Licensed User

    Hello,

    when i tested my app on the device today, i got an unspecified error message within a sub upon program start.I don't get this error on the desktop emu, so i didn't realize this for a longer time and believed everything is fine.

    I installed then the System_SR_ENU.CAB on my device to get a clue what the problem is.

    I get now this error:

    "Could not find the file \Temp\afilename"

    This error occurs while executing:

    Code:
    Sub Globals
    ...
    LogFileName = 
    "\Temp\myfile"
    ...
    End Sub


    If FileExist(LogFileName)  = true AND FileSize (LogfileName) > 0  =  true Then 
    FileOpen (FileHandle,LogFileName,cRead)
    ...
    Else
    MsgBox(LogFileName & " does not exist..!")
    End if
    ...
    End Sub
    If i use

    Code:
    FileOpen(LogFileHandle,LogFileName, cWrite ,cAppend,)
    later in the code, it properly creates the file without error message using the same path/file, the FileExist doesn't seem to like.

    As i already mentinoned, on the desktop no error message at all occurs, even if the file/path does not exist.That is what the check for is..:)

    By testing i found, that the ...FileSize (LogfileName) > 0 statement seems to be the problem.

    I assume now:

    - FileExist(file) works ok on Desktop and Device
    - FileSize(file) is generating an error, if (file) does not exist, on device, but not on desktop.

    Can anyone confirm that..? Is this a (know or unknown) bug..?


    cheers

    TWELVE
     
  2. Cableguy

    Cableguy Expert Licensed User

    y tadd the ApPahkeywo in he file path...

    something like...

    LogFileName = AppPath & "\Temp\myfile"

    You may be looking for the file in the wrong folder....
     
  3. TWELVE

    TWELVE Active Member Licensed User

    What's this..? :)

    If i was looking to the wrong file/path, how can i create the file then with FileOpen and the same path/file..? No please that's way to easy to be a solution for this
    difficulty thingy..:)
     
    Last edited: May 10, 2008
  4. Erel

    Erel Administrator Staff Member Licensed User

    If the file doesn't exist the program will not reach the FileSize method.
    Try to run your code from the device IDE and see which line raises the error.
     
  5. TWELVE

    TWELVE Active Member Licensed User

    The error occurs if the file does not exist, but only on device, as outlined above.

    I do it now this way:

    Code:
    If FileExist(LogFileName)  = true  Then 
      
    If FileSize (LogfileName) > 0  =  true Then
    Makes more sense, because i cannot ask the size of a file that doesn't exist.I didn't realize this because the error does not occur when run from desktop IDE.Probably on desktop the FileSize gives just zero as size back if the file does not exist, on the device is raises the error message.

    I found also some other differences between desktop and device ( sizing of gui elements/controls, font to large for a button, Tabcontrol not visible if the assigned form is too large in size...), which makes development a bit difficult.
    I cannot trust on the desktop and need to test the app on the device before i give that out to someone else.


    regards

    TWELVE
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    There is a syntax error in your code:
    Code:
    If FileExist(LogFileName)  = true AND FileSize (LogfileName) > 0  [B]=  true[/B] Then
    It should be:
    Code:
    If FileExist(LogFileName)  = true AND FileSize (LogfileName) > 0 Then
     
  7. TWELVE

    TWELVE Active Member Licensed User

    You're right :) Although i don't think that has caused the error message..do you..?

    cheers

    TWELVE
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    Basic4ppc uses "short circuit" conditions (like C operators: && and ||)
    Which means that if the file doesn't exist, its size will not be checked.
    Due to the syntax error the conditions were not checked correctly.
     
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