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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Releasing a file

Releasing a file

Scheduled Pinned Locked Moved C#
helpquestion
3 Posts 3 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.
  • Y Offline
    Y Offline
    Yevgeny Efter
    wrote on last edited by
    #1

    Hello! I have a strange question... I want to write a program that releases files that are in use by something I don't know... Actually, I don't know where to start... If someone could help, I would be very thankful... Thanks in advance!

    D J 2 Replies Last reply
    0
    • Y Yevgeny Efter

      Hello! I have a strange question... I want to write a program that releases files that are in use by something I don't know... Actually, I don't know where to start... If someone could help, I would be very thankful... Thanks in advance!

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

      First, you can't do that. The main reason is you don't control the file handle. Second, you can't clean up the resources in the app that has the file open in the first place. You'll only cause whatever app that is to crash because its file handle disappeared unexpectedly. Dave Kreskowiak Microsoft MVP - Visual Basic

      1 Reply Last reply
      0
      • Y Yevgeny Efter

        Hello! I have a strange question... I want to write a program that releases files that are in use by something I don't know... Actually, I don't know where to start... If someone could help, I would be very thankful... Thanks in advance!

        J Offline
        J Offline
        Judah Gabriel Himango
        wrote on last edited by
        #3

        Firstly, chances are you won't be able to do this solely from the .NET framework. You'll probably have to dip into the Win32 API to find out which processes have loaded a particular file handle. That's where you'll want to start, see how you can get that information from the Win32 API. Like Dave said, you couldn't really "unlock" the file. You could terminate the process that owns the file handle, if you can find out which process owns a particular file. And I don't know whether or not that's possible...I would guess it is, but I'm not knowledgeable enough to say.

        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