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. Why the open file handle ? [modified]

Why the open file handle ? [modified]

Scheduled Pinned Locked Moved C#
questionwindows-adminlinuxdebugginghelp
1 Posts 1 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.
  • R Offline
    R Offline
    Radu Sorin
    wrote on last edited by
    #1

    I am writing an simple application that will delete a file/directory. The application recives the target file as an argument. I have also put a shortcut in the W Explorer contextual menu, via Shell registry subkey of the folder entry in the HKEY_CLASSES_ROOT. [HKEY_CLASSES_ROOT\Folder\shell\NewMenuOption] @="Wipe it ..." [HKEY_CLASSES_ROOT\Folder\shell\NewMenuOption\command] @="D:\\FileWiper\\bin\\Debug\\FileWiper.exe \"%1\"" If a launch the program from a shell with an filename/folder as an argument it does it's job. But if the program is launched via the option in the Explorer menu and the selected targer is a folder (with a simple file it works), then the deleting fails with the exception " ... file being used by another process". It seems that the program keeps an open handle on the directory. The delete operation is made via Directory.Delete() ( tried also working with DirectoryInfo ...same result). Any one has any idea how can I get past this ? ------------------------------------------------------------------ LATER EDIT : I managed to track the problem after all. Simple stuff really, but forgot about it. Windows set the current directory for the program was set to be the target directory, so a simple change of the current directory was enough to get the program going. -- modified at 4:04 Friday 9th March, 2007

    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