I created simple wpf application (WpfApp1). I run it and everything was working fine. Then I tried to rebuild the solution and I received an error.
Error: Unable to copy file "obj\Debug\WpfApp1.exe" to "bin\Debug\WpfApp1.exe". Access to the path 'bin\Debug\WpfApp1.exe' is denied.
I restarted VS, cleaned and rebuilt the solution, checked by 'handle' if anything was blocking WpfApp1.exe file (handle "pathToTheFile\WpfApp1.exe"
result: Nthandle v4.1 - Handle viewer Copyright (C) 1997-2016 Mark Russinovich Sysinternals - www.sysinternals.com
No matching handles found.)
and I checked permission to the folder by right clicking on the folder -> properties -> security (3rd tab). I'm logged under local account with administrator privilages and I'm able to create, rename etc. other files in \bin folder but I'm not able to do anything with WpfApp1.exe file. I also run VS as an administrator and tried to do the same, but the error apeared.
I work on: win10 home, visual studio 2017 community (15.4.0)
EDIT: repair and reinstallation of VS hasn't helped.
After rebuild proces, .exe file from \bin is set as deleted, but somehow the file still exists on the disc as a 'ghost' file. In that moment access rights to the file are changed by OS and an owner of that file is unknown (I can't see it because of lack of permission. Before rebuild proces I had full access to the file.) If I restart OS, then the proces of deletion of the file is completed and the file doesn't exist anymore.