File component - File.Exists does not work for files in the assets with the APK - bug

i tried to delete it, but it seems not to work:


it should have deleted the file after writing it in label5 but it doesn't,

i can see the file have the correct path, but it still do not delete it, and the number of files in this directory getting higher then 1.

did you set the file scope to App?
for the File.Delete method try a relative path, which start wth /Pictures...

Taifun

as you can see in the second image, it give the correct path:

but still do not delete.

I can see that you are using an absolute path...
The suggestion was

Also what about

Taifun

i will try the relative path.

the file.delete have only file name, not a scope, i added the scope as the absolute path

As I've already showon in post #12:

If the FileScope = App you must set the subfolder and the fileName:
/Pictures/_app_inventor_image_picker/<fileName>

The File component does not use an absolute or full path.

1 Like

cool, thanks i try it now, i wished it was written in the documentation.

This is not a relative path, but the subfolder of the ASD and the fileName.
If you want to use a relative path you must set FileScope = Legacy.

See also here: Some basics on Android storage system

Btw, I also showed this in post #12:

yes i have read it already, but i do not know what components need what.

Rebuild my blocks and try ...

thanks, i will do that.

@Anke @Taifun thanks very much it worked.

1 Like

In this case relative means relative to the ASD folder

Taifun

Yes, I understand what you meant, but that would then require another definition in addition to

  • absolutive path
  • full path and
  • relative path

which could probably overwhelm or confuse most people.

relative ASD path ?

This doesn't mean relative to the root dir of the external storage, but relative to the ASD.
Relative path basically means relative to the root dir of the external storage (/storage/emulated/0/).

Exactly :slight_smile:

Yes, we understand that, but do the users also?

I guess the problems arise when filescope is not set to App....

The relative path is the path AFTER whatever the filescope sets as the endpoint.....