How to get while directory is using by any process or not in vb.net

I am creating a directory for my application...But want to delete it at the Page Disposed event. While doing that it is giving that the Directory is used by another process.....So I am not able to delete that one......How can I get that the directory is used by another process....and stop that process for deleting the particular directory...?

I need help. Thanks for helping me.

[396 byte] By [TapojjwalMandal] at [2008-1-9]
# 1
You'll know the directory is in use from the exception, there is no other way to check. If it is another process that locked the directory, you can't do anything about it. It may well be your own app. If you use OpenFileDialog, be sure to set the RestoreDirectory property to True.
nobugz at 2007-10-3 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 2

Hi Hans..

You are right..but I am extracting files in a new folder which I am creating by my program....But after doing everything...I want to delete that one...and at that time I am getting the exception.....So it is locked by some other process....Now my question is that...how to unlock that directory from other process?

TapojjwalMandal at 2007-10-3 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 3

Hi, Tapojjwal,

Based on your description, I think this folder is possibly locked by your own application.

As nobugz said in his post, it is really not so easy to check what process has locked this directory or unlock the directory in .Net.

So, please check if you have released all the resources after you creating and extracting the files.

If possible, please post some codes for that.

Regards

YuGuo–MSFT at 2007-10-3 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 4
We are changing the issue type to “Comment” because you have not followed up with the necessary information. If you have more time to look at the issue and provide more information, please feel free to change the issue type back to “Question” by editing your initial post and changing the radio button at the top of the post editor window. If the issue is resolved, we will appreciate it if you can share the solution so that the answer can be found and used by other community members having similar questions.
Thank you!

YuGuo–MSFT at 2007-10-3 > top of Msdn Tech,Windows Forms,Windows Forms General...