Has anyone done this in the context of a .NET application? The files I want to lock are all XML files; so far, I've simply used let the XmlSerializer close them as soon as it was done, which was convenient: the model underlying the view had to remember only the path, so Save and Close were trivial to implement. Now it seems that I'd have to open a FileStream, get the SafeHandle, pass that to LockFile (or LockFileEx) via P/Invoke, read the XML, close the FileStream (or not?), possibly save out the XML (since my process owns the lock, that *should* work) however many times I need to, and make darn sure that I finally release the lock via Dispose() when the MDI child window displaying the model closes/crashes.
I'm not asking how to do it, necessarily, as I clearly have some ideas. I'm wondering if anyone *has* already done it, and what problems they ran into, e.g. with the underlying HANDLE becoming invalid, etc. =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com