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.