Which process is using a file?

D

DBC User

I would like know is it possible someway to find out which process is
holding a file using c#? I have a problem where one file is been held
by some process (I don't have a clue) and I want to force delete that
file with out stopping the application or restarting the computer. Is
it possible or am I day dreaming?

Thanks.
 
T

Tim Van Wassenhove

DBC User schreef:
I would like know is it possible someway to find out which process is
holding a file using c#? I have a problem where one file is been held
by some process (I don't have a clue) and I want to force delete that
file with out stopping the application or restarting the computer. Is
it possible or am I day dreaming?

I'm not sure if this helps you (because it's not a c# solution), but I
have sucessfully used http://ccollomb.free.fr/unlocker/
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

It's not possible using a managed solution, you would have to P/invoke and
lot of it.

And even in case you can do it you will not be able to "tell" to the program
that has the file open to close it.
 
W

Willy Denoyette [MVP]

DBC User said:
I would like know is it possible someway to find out which process is
holding a file using c#? I have a problem where one file is been held
by some process (I don't have a clue) and I want to force delete that
file with out stopping the application or restarting the computer. Is
it possible or am I day dreaming?

Thanks.



There is no way to do this from user code (any language), and doing it from
kernel space means writing a filter driver.
Now, even if you could get at the owning process, how do you think that
process will behave if you start deleting it's files?

Willy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top