Listfiles error

JDS

Active Member
Licensed User
Longtime User
Good morning,

I've got the following code:

B4X:
File.Delete(Globaal.Map_Uren, Globaal.psFileToDeleteUren)
Globaal.psFileToDeleteUren = ""
Dim lListU As List: lListU.Initialize
lListU.Clear
If lListU.IsInitialized Then
lListU = File.ListFiles(Globaal.Map_Uren)
If lListU.Size>0 Then
        sNewFile = lListU.get(0)
   psFileToDeleteUren=sNewFile
....
end if

The situation is as follows:
The directory "Globaal.Map_Uren" contains serveral xml-files ("Globaal.Map_uren" = File.DirInternal & "/Uren"). These files are send and then the next file (and so on). At a certain point the directory (Globaal.Map_uren) is empty. But I check one more time to be sure "lListU = File.ListFiles(Globaal.Map_Uren)". At that point the application stops working. The strange part is that it works four (or more) times and when the directory is empty I get the following error:

B4X:
lListU = File.ListFiles(File.DirInternal & "/Uren")
java.io.IOException: /data/data/lmmobile.jds.android/files/Uren is not a folder.


   at anywheresoftware.b4a.objects.streams.File.ListFiles(File.java:154)
   at lmmobile.jds.android.globalservice._jobdone(globalservice.java:837)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at anywheresoftware.b4a.BA.raiseEvent2(BA.java:167)
   at anywheresoftware.b4a.keywords.Common$4.run(Common.java:885)
   at android.os.Handler.handleCallback(Handler.java:587)
   at android.os.Handler.dispatchMessage(Handler.java:92)
   at android.os.Looper.loop(Looper.java:150)
   at android.app.ActivityThread.main(ActivityThread.java:4277)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
   at dalvik.system.NativeStart.main(Native Method)
java.lang.RuntimeException: java.lang.RuntimeException: java.io.IOException: /data/data/lmmobile.jds.android/files/Uren is not a folder.
   at anywheresoftware.b4a.keywords.Common$4.run(Common.java:888)
   at android.os.Handler.handleCallback(Handler.java:587)
   at android.os.Handler.dispatchMessage(Handler.java:92)
   at android.os.Looper.loop(Looper.java:150)
   at android.app.ActivityThread.main(ActivityThread.java:4277)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
   at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.RuntimeException: java.io.IOException: /data/data/lmmobile.jds.android/files/Uren is not a folder.
   at anywheresoftware.b4a.BA.raiseEvent2(BA.java:193)
   at anywheresoftware.b4a.keywords.Common$4.run(Common.java:885)
   ... 9 more
Caused by: java.io.IOException: /data/data/lmmobile.jds.android/files/Uren is not a folder.
   at anywheresoftware.b4a.objects.streams.File.ListFiles(File.java:154)
   at lmmobile.jds.android.globalservice._jobdone(globalservice.java:837)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at anywheresoftware.b4a.BA.raiseEvent2(BA.java:167)
   ... 10 more

The same occures when I want to write quickly several files to this directory by pressing a button.
 
Last edited:

JDS

Active Member
Licensed User
Longtime User
I've updated the code-segment.
The first value in the list gets send and, when returning in this piece of code, deleted.
If it is the last file, does it delete the whole directory?
 
Upvote 0
Top