If you run the .exe and the output file is write protected (not checked out from sourcontrol for instance) the program crashes. I see 2 options: 1 Catch the exception (which always should be done). 2. Change the access modifiers (attrib -r).