Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2006-11-01
5
Medium Priority
?
278 Views
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?

Thanks,
BrianMc1958
0
Comment
Question by:BrianMc1958
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 86

Expert Comment

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

but be careful with that
0
 

Author Comment

by:BrianMc1958
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?

0
 
LVL 86

Accepted Solution

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

http://javaalmanac.com/egs/java.io/TraverseTree.html
0
 

Author Comment

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

Expert Comment

by:CEHJ
ID: 17851190
:-)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Suggested Courses

604 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