Normally, the application gets this error when it tries to access a file that is being used or locked by some another process.
Ensure that the file you are trying to access is not being used by any other process.
Following points could help you in troubleshooting:
- Ensure that the file is not opened in any editor or IDE i.e. Notepad, Visual Studio etc.
- Ensure that the file is not opened on the same machine by some other user in the same network. You can ask that user to verify if he/she has opened the same file in some process from his account.
- Ensure that you close the data stream once it has been used.