This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
You need to delete the files inside the directory before you can delete it. The contents may include directories which themselves might be nonempty so you are faced with the same problem.
The method first deletes the directory's contents and then finally deletes the directory itself. The method is recursive - if any of the contents are directories then they are in turn deleted in the same way.