2017년 8월 22일 화요일

Tip: Working with the File component .. a new way


Carlium von duik Essoterik

Edit: this was originally posted here:  file component needs ability to create new directory.    It is a very good tip and belongs in the Tips catagory.  Thank you Carlium for sharing with the AI2 community.

I know that is not cool resurrect old post but I consider that my point maybe is ok in this thread.  (Not a problem Carlium)
Using the file component save file with a structure or path like: /xxxx/xxx.txt does not work for me. I do not know why. But I find a way to create any folder in the SDCARD.
I attached the image here.
With this method I can put files, like csv, txt or jpg in folders, create many folders and put images in the folders (this last using a hide canvas and put a standard height and width, I am looking how to improve that)

Two very important thinks to consider:

1. To share files it is necessary put /sdcard/ in the path for example:  If you create a file like: /Folder/filename.csv you must share it with the follow path: /sdcard/Folder/filename.csv

2. To delete files from SDCARD you must ignore the /sdcard/ on the path and you can use the File.Delete block with the path: /Folder/filename.csv

Due it is imposible get the names of files in a folder, I use a tinyDB and save each image and use it for delete each image one by one. Still I cannot find a method to delete folder :(

See you and hope that this information works for all people that want to do that without third party apps.

--
Thanks Steve for move the post. 

I detect a issue :S. In the emulator, USB and Wifi debugging, works perfect!. But when the apk is compiled appears a error:

width and height must be > 0

The funny thing is that still with error the folder is created. I am tried to figure out what is going on with that, the canvas is the problem.

I hope that in the next version of AI2 management of files will be priority, that is very important and sadly I cannot contribute with them due my lack of knowledge.

---UPDATE---

Very difficult fix something when only the error comes in the apk :S
The method WORKS but only if the canvas is showed. You can put a very small canvas in the screen and everything is OK. never hide or something with the canvas before try to create the folder it is a complete nightmare ;)

--
It is possible to delete a folder simply using "/folder" with delete command but the folder has to be empty. 
Deleting the files is another issue, one at a time. Still trying to figure that one out.

--

댓글 없음:

댓글 쓰기