I have this really annoying issue with deleting directories in Windows for some time now.
I'm a software developer using Visual Studio and I usually have a common build output directory for one project and its subprojects if I find it suitable.
Now if I want to wipe any build artifacts I usually just delete this directory or at least I try.
Oftentimes I cannot delete the output directory directly and I get error messages like "You need permission from XXX to delete this directory".
XXX usually is the account I'm already logged in so I don't get that. I'm the local administrator of the machine and there is nothing special about the build output directory.

The only thing I can do is to remove everything inside the output directory and only then I can delete the top level build output directory.
Sometimes especially if I have several subdirectories for multiple configurations like "Release" and "Debug" I get the same error for those subdirectories as well and have to clear their contents beforehand, too.

There are no apparently open files/applications inside these directories or anything that I could notice preventing deletion of the files.

I searched the web but I couldn't find anything so far, I even don't know exactly what to look for.
What can I do about it or what may be the cause?

Edit: This issue doesn't always happen, there are days on which everything works but there are days on which it doesn't or at least part of the day doesn't work.

  • 1
    Your build stack probably sets messed up permissions, check them manually to see if anything is out of the ordinary (e.g. owning a file but not having permission to delete it). Workaround: try to build a script that recursively sets sensible permissions and then deletes the folder. – simlev Sep 15 '18 at 20:52
  • @simlev thanks for your comment. I should have mentioned that the issue doesn't always appear, it can happen for half the day and the other half it doesn't happen. I just use standard Visual Studio build stack but I'll have a look into permissions if this happens again – TorbenJ Sep 15 '18 at 21:41

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.