Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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.

like image 893
Daisetsu Avatar asked May 02 '11 17:05

Daisetsu


People also ask

How do you unlock a locked file?

Right-click on the file. In the menu that appears, select Lock File. To unlock, right-click the file and select Unlock File.

Does notepad lock file?

As you said, notepad cannot lock it exclusively. Luckily, declaring a streamreader locks a file exclusively unless you specify otherwise.


1 Answers

try this:

( >&2 pause ) >> yourfile.txt

>> opens yourfile.txt in append mode

see this for a reference

like image 78
Zahra Avatar answered Sep 28 '22 12:09

Zahra