2016년 11월 18일 금요일

Error 2101: the file could not be found


I looked to all thread regarding this but I'm still in trouble.
I've made an app than should read a csv file (picking it from internal memory) and import his content in a database.

I'm not able to reach this step cause every time it ends with "Error 2101: the file //storage/emulated/0/download/test.csv could not be found". But it exist, I've personally put it there!
I've tried everything (one slash, two slash, "file:///". "mnt/sdcard/") and nothing works, I can't go on.

Please help me to find out why. 
P.S. I have to put all that text replacement because AfterActivity.ResultURI it return a very strange string, here the code and what it returns:


-- 

 I have to put all that text replacement because AfterActivity.ResultURI it return a very strange string
how does that "strange string look like exactly?
to convert a content uri into a file, you can try to use the GetFileName method from the file extension https://puravidaapps.com/file.php



Error 2101: the file //storage/emulated/0/download/test.csv could not be found

why are there 2 slashes? there should be only one... probably that's the problem?

Taifun

-- 
Here's the answer:

The "Strange string":


With your extension:





With just one slash:



-- 
the file component expects a relative path, which is in your case 
/Download/test.csv


ReadFrom(text fileName)
Reads text from a file in storage. Prefix the filename with / to read from a specific file on the SD card (for example, /myFile.txt will read the file /sdcard/myFile.txt). To read assets packaged with an application (also works for the Companion) start the filename with // (two slashes). If a filename does not start with a slash, it will be read from the application's private storage (for packaged apps) and from /sdcard/AppInventor/data for the Companion.

my method can't provide something reasonable for that content uri
Taifun


-- 
Ok many thanks for your answer, Taifun (and very compliments for your extension!)

However it seems that in MIT APP Inventor there is no way to pick a file from a path (that isn't specified before) and read it

-- 
you could use my file extension to get a list of available files of a given path
and use a listpicker to pick a file

you also could build your own file manager using the blocks from the file extension
there are also blocks to get a list of directories etc.

Taifun

-- 
Ok I'm getting crazy.
I've tried what you suggest:


And I get the same result:


-- 
as already said
the file component expects a relative path, which is in your case 
/Download/test.csv


Taifun

-- 

댓글 없음:

댓글 쓰기