remove local directory
Hello everyone
I created a new dir in my app directory with
var parent = Titanium.Filesystem.getApplicationDataDirectory();
var new_folder = Titanium.Filesystem.getFile(parent, 'atlas');
new_folder.createDirectory();
Now i would to delete this directory and all it's content, I tryied whit
new_folder.removeDirectory();
but it seems don't work..!
Any help! Thank you!
4 Answers
-
Accepted Answer
According to the doc, by default deleteDirectory is not recursive. So if you have subfolders (or if the directory is not empty ?), I suppose you need to use the optional boolean parameter :
new_folder.deleteDirectory(true);
http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.Filesystem.File.deleteDirectory-method.html
-
Stefano
Just a small amendment to your code, and I think it will work. According to the Titanium.Filesystem.File docs, it's deleteDirectory() rather than removeDirectory().
Cheers
-
Sorry, it's true bu directory it's still here!
-
I have the same problem but i want to delete only the subdirectory when i use true with deleteDirectory i have /pdf/low all deleted any help thanks.
~~~ var parent =Titanium.Filesystem.applicationDataDirectory+'pdf'; var PdfDir = Titanium.Filesystem.getFile(parent,'low'); pdfDir.deleteDirectory(true); ~~~