Reputation: 7724
I am trying to create a file in my phone but I am always invoking only else part
app.component.ts
file.checkDir(file.dataDirectory, 'silapathigaram')
.then(_ => {
console.log('Directory exists');
})
.catch(err => {
console.log('Directory doesnt exist');
file.createDir('cordova.file.applicationDirectory', 'silapathigaram', false)
.then(
(files) => {
// do something
console.log("success");
}
).catch(
(err) => {
// do something
console.log("error"); // i am invoking only this part
}
);
});
what am I doing wrong? I am checking file name 'silapathigaram' and if it does not exist I am trying to create one
but I am invoking only error part my code
Upvotes: 3
Views: 3207
Reputation: 544
while creating the directory use code
file.createDir(file.externalRootDirectory, 'silapathigaram', true).then((val) => {
console.log("Created");
}).catch(e => {
console.log("error is ",e);
});
Upvotes: 1
Reputation: 29614
You have a small error. you need to send value of file.applicationDirectory
not the string literal 'cordova.file.applicationDirectory'
Change the call to:
file.createDir(file.applicationDirectory, 'silapathigaram', false)
Make sure to remove the single quotes as well.
Upvotes: 0