Which process is using a file?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • DBC User

    Which process is using a file?

    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.

  • Tim Van Wassenhove

    #2
    Re: Which process is using a file?

    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/

    --
    Tim Van Wassenhove - Read my mind <url:http://www.timvw.be/>

    Comment

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

      #3
      Re: Which process is using a file?

      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.

      "DBC User" <dbcuser@gmail. comwrote in message
      news:1179154177 .054666.194550@ k79g2000hse.goo glegroups.com.. .
      >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.
      >

      Comment

      • Willy Denoyette [MVP]

        #4
        Re: Which process is using a file?

        "DBC User" <dbcuser@gmail. comwrote in message
        news:1179154177 .054666.194550@ k79g2000hse.goo glegroups.com.. .
        >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.

        Comment

        Working...