file.removeDir() INVALID_MODIFICATION_ERR (code: 9)

I’m using cordova-plugin-file to try to remove a directory, but I’m getting “INVALID_MODIFICATION_ERR (code: 9)” error.
file.checkDir() says that file exists, but when I try to remove ir i got that error.

this.file.removeDir(this.file.dataDirectory, 'images')
			.then(entry =>{
					console.log('pasta images deletada');
					//return this.file.copyDir(this.file.applicationDirectory + 'www/', 'images', this.file.dataDirectory, 'images')
				.catch(err =>{

Am I forgetting something?
Thank you

I solved my problem. I can remove the directory using file.removeRecursively() method.


Thanks! Worked For me as well.

When deleting a directory, the directory must be empty or the remove operation will fail. To remove a directory that contain files, use the removeRecursively method, which will empty the directory before removing it.

Ref: Wargo, J. (2014). Apache Cordova API Cookbook. Addison Wesley Professional. 1st Edition. pp 173

Thank you man.
You saved my life :smiley: