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. Delete files that are in use

Delete files that are in use

Scheduled Pinned Locked Moved C#
sysadminquestion
4 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.
  • O Offline
    O Offline
    Ola Carlsson
    wrote on last edited by
    #1

    Hi, I need to delete files that are in use. I can´t restart my computer or neither exit programs that are using them. Any suggestions? Need to work on NT/2000 server. /Ola Carlsson

    P 1 Reply Last reply
    0
    • O Ola Carlsson

      Hi, I need to delete files that are in use. I can´t restart my computer or neither exit programs that are using them. Any suggestions? Need to work on NT/2000 server. /Ola Carlsson

      P Offline
      P Offline
      Paul Riley
      wrote on last edited by
      #2

      You can't delete a file that's in use - that could break someone else's running program. You can mark them for deletion on reboot or you can kill the other programs that are using it. Paul Why don't you take a good look at yourself and describe what you see - Led Zeppelin, Misty Mountain Hop

      J 1 Reply Last reply
      0
      • P Paul Riley

        You can't delete a file that's in use - that could break someone else's running program. You can mark them for deletion on reboot or you can kill the other programs that are using it. Paul Why don't you take a good look at yourself and describe what you see - Led Zeppelin, Misty Mountain Hop

        J Offline
        J Offline
        JasonSmith
        wrote on last edited by
        #3

        How do you mark a file for deletion on reboot? I didn't know you could do that! Do tell!

        P 1 Reply Last reply
        0
        • J JasonSmith

          How do you mark a file for deletion on reboot? I didn't know you could do that! Do tell!

          P Offline
          P Offline
          Paul Riley
          wrote on last edited by
          #4

          Registry Key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\ Name=PendingFileRenameOperations Type=REG_SZ_MULTI Entry=filename.txt\0\0 Or using the Win32 API, you can use MoveFileEx with a null destination file and MOVE_DELAY_UNTIL_REBOOT. [edit]Probably worth noting, in case someone comes searching later that the first approach doesn't work on Win 9x or ME, only on NT/2K/XP. To use in 9X, you have to store some details in WININIT.INI; to use in all versions of Windows, MoveFileEx is probably your best bet.[/edit] Paul Why don't you take a good look at yourself and describe what you see - Led Zeppelin, Misty Mountain Hop

          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