?
Solved

NEWBIE: Delete of directory seems to fail

Posted on 2006-11-01
7
Medium Priority
?
228 Views
Last Modified: 2010-03-31
Dear Experts,

I'm trying to delete a directory (on W2K box), like this:

      File dummyFile = new File(dirName);
      dummyFile.delete();
      dummyFile = null;

It works at home, but not at my customer's site.  How come?

The .delete is not set up to throw an exception.  Doesn't that seem strange?  Normally, all IO operations do that, right?

Thanks,
BrianMc1958
0
Comment
Question by:BrianMc1958
  • 5
  • 2
7 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 2000 total points
ID: 17850746
Is it empty (won't work otherwise)?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 17850761
You can of course tell if it hasn't worked by the fact that it would have returned false
0
 

Author Comment

by:BrianMc1958
ID: 17850785
Oh.  Didn't know it had to be empty.  Also didn't know it returned boolean.  Let me try...
0
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.

 
LVL 86

Expert Comment

by:CEHJ
ID: 17850839
If it's not

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

but be careful with that
0
 

Author Comment

by:BrianMc1958
ID: 17850888
This would be my mistake-of-the-week.  Would have sworn it was working fine.  I'll post a follow up.  Thanks one more time...
--BrianMc1958
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 17850931
:-)
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 17850937
It was probably empty when you tried it ;-)
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

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

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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
Course of the Month17 days, 2 hours left to enroll

862 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