Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Get the process-name that locked the file

Get the process-name that locked the file

Scheduled Pinned Locked Moved C#
question
19 Posts 7 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Dave Kreskowiak

    I didn't have a problem with what your question was. I was just saying why you see that discussion all over the web and noone really answering the question.

    A guide to posting questions on CodeProject[^]
    Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
         2006, 2007, 2008
    But no longer in 2009...

    B Offline
    B Offline
    Bjorn T J M Spruit
    wrote on last edited by
    #10

    Fair enough. And it's something I see more often. But it's not up to others to decide the validity of the question. A question was asked, why not answer it and then ask why someone is asking it, if one is truly interested? I can understand why some would feel frustrated with the ivory tower some developers are hiding in. The relevance of a question can only questioned by the one asking it, imo.

    1 Reply Last reply
    0
    • B Bjorn T J M Spruit

      Of course... there's always one that can't resist... Fine, I'll indulge you: I want to give someone the ability to see which process is locking a textfile. There's a reason they want to know and I'm not inclined to debate their need to know. Honestly... I don't care why they want to know. They know not to go shutting down running processes willynilly, so that's not a concern. Actually, whatever it is they want to do, from the point where they know which process is locking the file, isn't my concern. What IS my concern, is to provide the very basic functionality of showing them which process is locking the file. Lets hope this rant discourages anybody else that feels the need to debate the question or the validity of it. Unbelievable that you didn't pick up the 'hint': **The validity of the question is not up for debate** Alrighty ?

      J Offline
      J Offline
      J4amieC
      wrote on last edited by
      #11

      The reason there is always a debate on why this is a valid question, in my opinion, is that 90% of the time it is the programmers actual program that is holding onto the file by not disposing of its resources before trying to delete the file. So when your users want to know what is locking a file, are they going to see that it is another part of your code?

      B 1 Reply Last reply
      0
      • J J4amieC

        The reason there is always a debate on why this is a valid question, in my opinion, is that 90% of the time it is the programmers actual program that is holding onto the file by not disposing of its resources before trying to delete the file. So when your users want to know what is locking a file, are they going to see that it is another part of your code?

        B Offline
        B Offline
        Bjorn T J M Spruit
        wrote on last edited by
        #12

        I see your point. Though, you'd get to the same point when a developer finds out, that the process it returns, is the one the developer is debugging or has built. It's much more effective if a developer is forced to assume responsibility for oneself,with the shaming conclusion that the developer in question needs to kick one's own behind. My point being, give what is asked for and engage in conversation as to what the context is. It'll result in a more social event that way. And as to answer your question, I think that what the user is going to see, is that they still have something like Ultra Edit/Notepad/etc... is still holding the file and they forgot to close the text editor before testing/running their application. If the question is:"Is it likely to be something silly?", the answer is most likely yes. In the end, however, that's besides the point. I'd prefer they'd find out for themselves in an easy way, instead of them having to bother me. I'm all for self-reliance. ;)

        D 1 Reply Last reply
        0
        • R Rob Philpott

          Some obscure API call no doubt. You'll probably need to iterate through processes or something. Here's an article with source code that does it, although it's C++, it may give you some pointers. http://www.kartmann.org/freeware/WhoSLocking/ReadMe.htm

          Regards, Rob Philpott.

          E Offline
          E Offline
          Ennis Ray Lynch Jr
          wrote on last edited by
          #13

          C++ may give you some pointers?

          Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. A man said to the universe: "Sir I exist!" "However," replied the universe, "The fact has not created in me A sense of obligation." --Stephen Crane

          R 1 Reply Last reply
          0
          • B Bjorn T J M Spruit

            Of course... there's always one that can't resist... Fine, I'll indulge you: I want to give someone the ability to see which process is locking a textfile. There's a reason they want to know and I'm not inclined to debate their need to know. Honestly... I don't care why they want to know. They know not to go shutting down running processes willynilly, so that's not a concern. Actually, whatever it is they want to do, from the point where they know which process is locking the file, isn't my concern. What IS my concern, is to provide the very basic functionality of showing them which process is locking the file. Lets hope this rant discourages anybody else that feels the need to debate the question or the validity of it. Unbelievable that you didn't pick up the 'hint': **The validity of the question is not up for debate** Alrighty ?

            E Offline
            E Offline
            Ennis Ray Lynch Jr
            wrote on last edited by
            #14

            That is why I stopped asking questions on the Internet. Too many people who don't have the answer feel inclined to respond without realizing all they are doing is wasting someone else's time. Of course, I am doing that right now since I don't have the answer either but I am at least self-aware making me an A**hole and not a moron.

            Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. A man said to the universe: "Sir I exist!" "However," replied the universe, "The fact has not created in me A sense of obligation." --Stephen Crane

            J 1 Reply Last reply
            0
            • E Ennis Ray Lynch Jr

              C++ may give you some pointers?

              Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. A man said to the universe: "Sir I exist!" "However," replied the universe, "The fact has not created in me A sense of obligation." --Stephen Crane

              R Offline
              R Offline
              Rob Philpott
              wrote on last edited by
              #15

              Ta-Dah! :)

              Regards, Rob Philpott.

              1 Reply Last reply
              0
              • E Ennis Ray Lynch Jr

                That is why I stopped asking questions on the Internet. Too many people who don't have the answer feel inclined to respond without realizing all they are doing is wasting someone else's time. Of course, I am doing that right now since I don't have the answer either but I am at least self-aware making me an A**hole and not a moron.

                Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. A man said to the universe: "Sir I exist!" "However," replied the universe, "The fact has not created in me A sense of obligation." --Stephen Crane

                J Offline
                J Offline
                J4amieC
                wrote on last edited by
                #16

                Do you know what, ive pretty much stoped answering questions on the internet for exactly the opposite reason - people get uppity when you actually question why they are trying to do something one way when there is a reason we don't generally do it that way.

                E 1 Reply Last reply
                0
                • J J4amieC

                  Do you know what, ive pretty much stoped answering questions on the internet for exactly the opposite reason - people get uppity when you actually question why they are trying to do something one way when there is a reason we don't generally do it that way.

                  E Offline
                  E Offline
                  Ennis Ray Lynch Jr
                  wrote on last edited by
                  #17

                  There is a difference between questioning a novice developers approach and questioning an experienced developers question.

                  Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. A man said to the universe: "Sir I exist!" "However," replied the universe, "The fact has not created in me A sense of obligation." --Stephen Crane

                  B 1 Reply Last reply
                  0
                  • B Bjorn T J M Spruit

                    I see your point. Though, you'd get to the same point when a developer finds out, that the process it returns, is the one the developer is debugging or has built. It's much more effective if a developer is forced to assume responsibility for oneself,with the shaming conclusion that the developer in question needs to kick one's own behind. My point being, give what is asked for and engage in conversation as to what the context is. It'll result in a more social event that way. And as to answer your question, I think that what the user is going to see, is that they still have something like Ultra Edit/Notepad/etc... is still holding the file and they forgot to close the text editor before testing/running their application. If the question is:"Is it likely to be something silly?", the answer is most likely yes. In the end, however, that's besides the point. I'd prefer they'd find out for themselves in an easy way, instead of them having to bother me. I'm all for self-reliance. ;)

                    D Offline
                    D Offline
                    Dave Kreskowiak
                    wrote on last edited by
                    #18

                    Björn T.J.M. Spruit wrote:

                    Though, you'd get to the same point when a developer finds out, that the process it returns, is the one the developer is debugging or has built.

                    Why have that developer (who can't figure out his own app locked a file) go through the pain of writing another app he doesn't understand just to find out he screwed up in his original app?

                    Björn T.J.M. Spruit wrote:

                    I'd prefer they'd find out for themselves in an easy way, instead of them having to bother me.

                    Most of the people who are asking the question don't have a clue about what they're doing, let alone have the ability to teach themselves anything.

                    Björn T.J.M. Spruit wrote:

                    I'm all for self-reliance

                    Björn T.J.M. Spruit wrote:

                    I'm all for self-reliance.

                    So am I. Too bad this business has been overrun by idiots who couldn't teach themselves how to use Notepad let alone how get to Yahoo or Google and do any kind of research whatsoever.

                    A guide to posting questions on CodeProject[^]
                    Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                         2006, 2007, 2008
                    But no longer in 2009...

                    1 Reply Last reply
                    0
                    • E Ennis Ray Lynch Jr

                      There is a difference between questioning a novice developers approach and questioning an experienced developers question.

                      Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. A man said to the universe: "Sir I exist!" "However," replied the universe, "The fact has not created in me A sense of obligation." --Stephen Crane

                      B Offline
                      B Offline
                      Bjorn T J M Spruit
                      wrote on last edited by
                      #19

                      And so the elitists decide whether they feel like helping or not. Mostly deciding whether they deem it worthy of their time and effort. Helping isn't performing an act in furthering yourself, it's an act of furthering others. A concept, it seems, hard to grasp for some. And yes, I'm not a novice. And yes, my question is valid and I'll not have that debated. So in the interest of furthering the one that asked a valid question, I gladly refer to the original post. Any insights, other than the ones given, are welcome.

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups