File locking

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
--
 
P

Patrice

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)...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top