This error could be caused by outputting to a file on a read-only folder such as "C:\Program Files".
- Avoid writing to a read-only directory (this might even be the directory in which you are running your application)
- Specify a full path name
- Make sure the target folder itself exists
For further information please see Microsoft's list of Windows error codes