Getting errors when trying to access locked files is a common situation that must be addressed by programs. On Windows machines it’s fairly easy to replicate the scenario of a locked file using a simple technique that I picked up recently. Simply run the following command with notepad.
notepad >> filename.txt
The file will remain locked until Notepad is closed. No need to an additional tool or utility to apply a lock to a file.