Search The Blog
About this site

@RoyOsherove

Subscribe!

This site aims to connect all the dots of my online activities - from tools, books blogs and twitter accounts, to upcoming conferences, engagements and user group talks.

from 5whys.com
Twitter: @RoyOsherove
My Book: The Art of Unit Testing
Latest Posts
« TechEd Israel Reflection Slides and Demos + organizational feedback | Main | Interactive MAD Fold-ins - coolness »
Wednesday
Apr092008

Fix: Cannot copy file 'X' to file 'Y'. The process cannot access the file because it is being used by another process. in Visual Studio 2008

This just saved me loads of time(especially because it only happened every once in a while):

if you encounter the amazingly annoying "Cannot copy file because it is being used by another process" when you want to rebuild or rerun a project in vs (for me it was always the test project), you can put the following in the pre-build event of the project that is having problems:

if exist "$(TargetPath).locked" del "$(TargetPath).locked"
if not exist "$(TargetPath).locked" move "$(TargetPath)" "$(TargetPath).locked"

 

for me personally the problem was a specific file that my project was testing against that was locked, so I changed it to be the following:

if exist "SOME_DLL.locked" del "SOME_DLL.locked"
if not exist "SOME_DLL.locked" move "SOME_DLL" "SOME_DLL.locked"

PrintView Printer Friendly Version

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>