Search code examples
visual-studio-2010visual-studiovisual-studio-2008unlock

After removing a Visual Studio Project from a Solution cannot delete the folder in windows


When I 'Remove' a project from a Visual Studio solution I often want to delete it. As some other posts on SO have mentioned this does not delete the physical project from the file system.

The larger problem here is that after removing the project form the solution when I attempt to delete the directory from windows Explorer or the command line it will not delete because Visual Studio still has it locked.

Usually, I am able to resolve this by exiting Visual Studio then doing the delete. But, occasionally I have had to log off and back on before being able to delete the directory.

I have had this problem in VS2008, VS2010 and probably the earlier versions as well.

My question is, if there is no way to do this delete from inside Visual Studio, is there at least a way to get it to let go of the file(s) that it has locked?


Solution

  • You could use Process Explorer, which allows you to close specific handles a program is holding onto. Just open it up, find the Visual Studio process (devenv.exe), use View/Lower Pane View/Handles, locate the proper handle in the lower pane, right-click it and choose "Close Handle". May not be ideal, but sometimes this is better than closing your app or killing the process.