 <p>The second will work fine, so long as the directory to be deleted does not contain any subdirectories. To clean out subdirectories, a recursive function is the best way, which is why in the first code sample the function <code>deleteFilesAndDirectory()</code> calls itself.</p>