How to access folder created using cordova file plugin


#1

I am using Ionic framework for hybrid app development. I am using cordova file plugin. With this plugin I have created a folder named ‘NewFolder’ like

  $scope.createFolder = function() {
  $cordovaFile.createDir(cordova.file.externalRootDirectory, "NewFolder", false)
     .then(function (success) {
      console.log("Folder created" + success);
     }, function (error) {
     console.log("Folder not created." + error);
     });
  } 

Now I have downloaded some images in this created folder. But I am not able to find it how to access its path. I am trying to use

 $scope.checkFileExist  = function() {
    $cordovaFile.checkFile( path, "file.txt")
   .then(function (success) {
     // success
    }, function (error) {
    // error
    });
  }

#2

you should define your scope function correct:

$scope.checkFileExist() { ... }

should be

$scope.checkFileExists = function () { ... };

#3

I wrongly typed the function here. I have edited it. My actual concern is -
I have created a folder to store images but when I download the image in this folder I need to check whether that image already exist in that folder or not. I am not able to find the path. For your reference I am talking about below path.

          $scordovaFile.checkFile (path , "file.txt")

#4

If you create the folder you get the path and the directory name as parameter in the success function.

After you downloaded the file you had to set the filepath and name.
you have to use this path + filename in the checkFile-Function.


#5

Please refer this, I have created folder using the filesystem listed here. So how can I access it using filesystem ?
http://ngcordova.com/docs/plugins/file/