3
我有一個可以創建文件的工作應用程序。 我正在尋找一種方法,在工作幾個小時後從Cordova應用程序中刪除文件。我似乎無法使其工作。Cordova刪除文件
這裏是創建和刪除文件的代碼:
function crea(){
alert(cordova.file.externalDataDirectory);
window.resolveLocalFileSystemURL(cordova.file.externalDataDirectory, function(dir) {
alert("got main dir",dir);
dir.getFile("log1.txt", {create:true}, function(file) {
alert("got the file", file);
});
});
}
function del(){
var relativeFilePath = cordova.file.dataDirectory;
var filename = "log1.txt";
alert(relativeFilePath);
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSystem){
// alert(fileSystem.root.fullPath);
fileSystem.root.getFile(relativeFilePath + filename, {create:false}, function(fileEntry){
fileEntry.remove(function(file){
alert("File removed!");
},function(){
alert("error deleting the file " + error.code);
});
},function(){
alert("file does not exist");
});
},function(evt){
alert(evt.target.error.code);
});
}
問候。
你的錯誤處理程序,需要有傳遞給它的 「錯誤」爲它工作。 –