Fog Creek Software
Discussion Board

Welcome! and rules

Joel on Software

Directory.Delete fails, but explorer doesn't?

Hey guys,

I'm a server side unix developer, so forgive me if this is an obvious question.

I have simple Windows Forms application that is really just a NotifyIcon with a context menu.  One of the menu Items does the following when selected:

1) Backup a directory (using the awesome #ziplib)
2) Directory.delete(directory, true); // recurse
3) Unzip the new version.

However, step 2 throws IOExceptions claiming that one of the files (it's always different, appears to be random) is in use by another process.  If I repeat the action step 2 will throw the exception again, with the same file this time.

I can just open the directory in explorer, select all and delete.  No errors or warnings for explorer, it just works.

Is there something obvious I'm missing?  If it's 'in use' for my application, shouldn't it be 'in use' for explorer too?  So this led me to belive that explorer was locking the file.  The error happens irrespective of whether explorer is viewing the directory or not.  Could it be my app locking the file some how?  I clean up all file handles from the zipping process....

Is there any windows equivalent to lsof?  i.e Show me all the files locked by each process?

New to windows clients
Thursday, July 22, 2004

handle. from

Thursday, July 22, 2004

*  Recent Topics

*  Fog Creek Home