[Tizen Application-dev] Read file with Filesystem API

Denis Sapon sapondenis at gmail.com
Thu Feb 16 19:20:08 GMT 2012


Hi,

I tried use WAC Filesystem API. I was able to create a file and write
it,  but I are not able to read it. I tried two approaches but both
have failed
In first case I use example from documentation for readAsText function
from File class. I got SECURITY_ERROR: DOM Exception 18 when call
readAsText
In second case I use openStream function, but got IO error(see code below):

 function successCB(files) {
   for(var i = 0; files.length; i++) {
     alert("File Name is " + files[i].name); // displays file name
     if (files[i].isDirectory == false)
       files[i].openStream(
           function(fs){
             alert("The file content " + fs.read(fs.bytesAvailable));
             fs.close();
           }, function(e){
             alert("Error " + e.message + " " + e.code);
           }, "r","UTF-8"
       );
   }
 }

 function errorCB(error) {
   alert("The error " + error.message + " occurred when listing the
files in the selected folder");
 }

 var documentsDir;
 deviceapis.filesystem.resolve(
     function(dir){
       documentsDir = dir;
       dir.listFiles(successCB,errorCB);
     }, function(e) {
       alert("Error" + e.message);
     }, 'documents', "rw"
 );

I would appreciate any hint

--Thanks,
Denis


More information about the Application-dev mailing list