I am developing an application in C# (.NET), and am having trouble dealing with file locking.
though I have not used it, but named Mutex can save your day. Before opening a file in application A, create a mutext like this:
Mutex(bool initiallyOwned, string name, out bool createdNew)
pass file name as second parameter.
now when you open a file in application B, again use Mutex if out parameter createdNew is false then file is already opened by A so you can only read it.