File locking

  • Thread starter Thread starter Giulio Petrucci
  • Start date Start date
G

Giulio Petrucci

Hi there,

How can I:
- lock a file foo.xml to write/append it and avoid other processes to
read/write it?
- verify if a file is locked and wait for it to be unlocked to read and
modify it?

Thanks in advance,
Giulio
--
 
Hi,
How can I:
- lock a file foo.xml to write/append it and avoid other processes to
read/write it?
- verify if a file is locked and wait for it to be unlocked to read and
modify it?

See :
http://msdn.microsoft.com/en-us/library/7db28s3c.aspx and the "share"
parameter. You'll have an IOException if you try to open a locked file
(you'll have to pause and wait yourself with possibly a retry count or a
timeout in case the file remains locked)...
 
Back
Top