Как удалить файлы в каталоге в ioni c, используя removeDir () или любым другим способом? - PullRequest
0 голосов
/ 17 апреля 2020

Я хочу удалить файлы в mydirectory, но когда я пытаюсь удалить его, он собирается поймать блок и выдает ошибку File_Not_Found. Здесь я сохраняю все мои файлы в массив и нажимаю на имя и путь. Но удалить не работает. Home.ts

listAllFiles(){
    this.platform.ready().then(() => {
      this.file.listDir(this.file.externalRootDirectory, MEDIA_FOLDER_NAME)

        .then((listfiles) => {
          for(let item of listfiles){

            if (item.isFile == true) {
              this.saveFileToArray(item);
            }
        }

        })
        .catch((err) =>{
        alert(JSON.stringify(err));
      });
    })
  }

//Saving all the files and passing to saveFileToArray

  saveFileToArray(item) {
    let extn = item.fullPath.split(".").pop();
      if (extn == 'mp3' || extn == 'm4a' || extn == 'mp4' || extn == 'pdf') {
          console.log("mp3 amd mp4 found");
          this.showFiles.push({
            name: item.name,
          path: item.fullPath
        })
    }
   }

deleteValuesFunction(item){

    let path=this.file.externalRootDirectory;
    let filename=item.name;
    this.file.removeFile(path, filename)
    .then((resultValue) => {
    alert("SuccessFully Deleted" + JSON.stringify(resultValue));
    })
  .catch((error)=> {
      alert("File not Deleted" +JSON.stringify(error));
    });
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...