Unable to copy a file from obj\Debug to bin\Debug

This should work.

Go to your project properties.
Inside Build Events, under Pre-build event command line, add these two lines of code:

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

Leave a Comment