How can I simulate a "locked" file (one which has a write lock)

Daisetsu picture Daisetsu · May 2, 2011 · Viewed 9.3k times · Source

I am trying to debug a problem where users occasionally have locked files which they try to open. The code appears to have correct exception handling but users are still reporting seeing error messages. How can I simulate a locked file so that I can debug this myself?

EDIT: For Windows.

Answer

Zahra picture Zahra · May 11, 2015

try this:

( >&2 pause ) >> yourfile.txt

>> opens yourfile.txt in append mode

see this for a reference