Example error text
WriteTextFile() could not open the file "C:\Temp\Result data.txt" for writing for the following reason: Error 020: The process cannot access the file because it is being used by another process.
This error occurs when the indicated file could not be opened for writing. The cause of error is reported by the operating system, and could be due any of several possible causes. The additional detail can help to diagnose the particular cause.
Some Possible causes
Error 03: The system cannot find the path specified
The directory that you have specified in the file name doesn't exist. You have most likely misspelled something in your file path.
Error 05: Access is denied.
You are attempting to write to a directory with access permissions that deny the your account write permission. You'll probably need to change (or have a sys admin change) the directory permissions, or you'll need to change your model to write to a different directory.
To find the name of the account you are running under, evaluate:
Error 20: In use by another process
Another program has this file open, disallowing it to be replaced.
First, you should just try evaluating again. Occasionally a process will open a file for a second, but it just happens to be that same second that your model tried to write, so by the time you retry, the file has been released at it works. Some backup software has been know to do this when you try to write the file at the moment when the previous version is being backed up. If you want to automate the retry in your model, you can catch the error using Try.
If it doesn't work on the second try, then you'll need to figure out which process this is, and close the file in that process before writing. I've had this happen when viewing the contents of a file in TextPad in binary view.