>>So, this is the answer on the second part of your question. Most likely if your application will not be shutdown properly, the file will remain locked. I do remember long time ago we did unlock files using some special tool.
>
>Therefore I cannot use this semaphore locking approach. Because sooner or later it will fail and there will be a problem. So I will work on another approach.
Actually I think the semaphore file approach is slower for what you're trying to achieve. The whole idea of client-server is to do as much on the server as possible, and pass only commands and results across the wire. Directory access is among slower things in that respect (just remember the issues with path in the fxp we had this week). On top of that, there are issues with special folders, UAC, virtualization etc, so the behavior of a folder may not be what you expect, and it may change because some IT cerberus may wake up thinking he hasn't done enough and tries to introduce yet another security measure without telling anyone.
Also, some of the versions of network protocol under Windowses may decide that you shouldn't keep a file open for too long, and may just decide to close it for you. I've seen it several times since Windows 98, it's a feature that gets turned on or off under mysterious circumstances, never caught any logic to it.