NEWBIE: How to delete all files in a directory? (W2k)

Posted on 2006-11-01
Last Modified: 2010-03-31
Dear Experts,

Is there a simple way to delete all files in a W2K directory, without actually getting a list of all names and looping?

Question by:BrianMc1958
  • 3
  • 2
LVL 86

Expert Comment

ID: 17850929
Runtime.getRuntime().exec("cmd.exe /C rmdir /SQ " + dirName);

but be careful with that

Author Comment

ID: 17851000
Seems like I've heard that before somewhere...

Although you have answered my question, I'd like to heed your warning and not use it.  I also try to avoid Runtime.
(I'll still split points if anyone else responds...)  

Does anyone know a simple way to do it otherwise?

LVL 86

Accepted Solution

CEHJ earned 500 total points
ID: 17851029
No - you will have to recurse all files/dirs and delete them first.

Author Comment

ID: 17851153
Got it.  Thanks.  That will be very helpful in the future, too.
LVL 86

Expert Comment

ID: 17851190

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
maven project error 5 56
replace a word with other 1 44
javap bin 2 36
by zero exception 10 41
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question