Link to home
Start Free TrialLog in
Avatar of BrianMc1958
BrianMc1958

asked on

NEWBIE: Delete of directory seems to fail

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
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You can of course tell if it hasn't worked by the fact that it would have returned false
Avatar of BrianMc1958
BrianMc1958

ASKER

Oh.  Didn't know it had to be empty.  Also didn't know it returned boolean.  Let me try...
If it's not

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

but be careful with that
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
:-)
It was probably empty when you tried it ;-)