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

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:

B4X:
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

B4X:
 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
 

Cableguy

Expert
Licensed User
Longtime 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....
 

TWELVE

Active Member
Licensed User
y tadd the ApPahkeywo in he file path...

What's this..? :)

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

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:

Erel

B4X founder
Staff member
Licensed User
Longtime User
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.

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.
 

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:

B4X:
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
 
Top