AnsweredAssumed Answered

How to check is a Map Document is already open/in use by another application

Question asked by jjoalland13 on May 9, 2012
Latest reply on May 21, 2012 by jjoalland13
I am developing a standalone application in C#/VS 2010 - ArcGIS Engine 10 which will run on several computer.
All my MXD files and associated data will be stored on only one computer and accessed by all, either by my application or ArcMap which is also installed on these computers.

my problem is simple :
How can I check programmaticaly that a Map Document is not already opened by ArcMap or ArcGIS Engine ? when I test, I open my mxd with ArcMap, then execute my application which try to open, change and then save it.
I though i could use the get_IsReadOnly before saving it, but it's not working :

    IMapDocument _mapDoc = new MapDocumentClass();
    _mapDoc.Open(sFilename, string.Empty);
    if (_mapDoc.get_IsReadOnly(sFilename))          -> return "false" even if the map document is already opened in ArcMap... I was expecting "true"
    _mapDoc.Save(true, false);                                                -> if already open somewhere else then I catch an Exception !

The exception is : a share violation has occured. (Exception from HRESULT: 0x80030020 (STG_E_SHAREVIOLATION))

so How can I chek if the mxd file is already opened somewhere else before working with it in my application ?