Reputation: 15015
I'm trying to build a project using Visual Studio 2008, but I'm getting this error:
Could not delete file '<filename>'. Make sure that the file is not open by another process and is not write-protected.
The file is most definitely not write protected (it was, but I changed it), and I don't think it's in use by some other process because I can delete it without a problem in windows explorer.
What might prevent Visual Studio from deleting it?
Upvotes: 0
Views: 943
Reputation: 1325
I fixed this error as follows:
I'm not sure why VC2008 has this problem but I'm guessing that it has a separate thread that's always scanning files in $(SolutionDir) and randomly preventing them from being deleted. When I had Output Directory within $(SolutionDir) I would randomly get errors trying to delete files during build and it seemed it could happen on any file. My builds would fail as a result about 90% of the time. Running VC as Administrator as suggested in comments below the original question did not fix the problem for me, nor did replacing all file permissions, running chkdsk /F, or rebooting. I would also theorize that this problem becomes gradually worse as your project becomes larger and more complex.
Upvotes: 1