Solved

NEWBIE: Delete of directory seems to fail

Posted on 2006-11-01
7
215 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 500 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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
mapShare challenge 13 70
JUnit 4 @Before and @BeforeClass differences 3 24
GUI builder for Eclipse? 8 14
Java Loop 6 25
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now