Here in this post I created a java program which deletes the directories which are non empty.
In this program I have used recursion approach to delete the directory which is not empty.Program continuously searches the bottom most folder in directory tree deletes it then return back to its parent and deletes it.This process is completed when recursion reaches the root directory i.e parent folder of all child folder.Delete that parent folder and we are done.
In this program I have used recursion approach to delete the directory which is not empty.Program continuously searches the bottom most folder in directory tree deletes it then return back to its parent and deletes it.This process is completed when recursion reaches the root directory i.e parent folder of all child folder.Delete that parent folder and we are done.
Download Source Code for this Application: DelDir.rar
There are some folders which say "access Denied"..
ReplyDeleteCan it delete such folders..??
Hi Anuj
ReplyDeleteWe can certainly delete the files with access denied prompt but it requires sophisticated java api and this simple program is just a demo with core api of java.