C# Visual Studio add-in - detect when saving document

柔情痞子 提交于 2019-12-11 03:55:12

问题


I'm working on a Visual Studio 11 add-in. Through code, how can I detect when the current active document is saved? I don't know where to begin, and I couldn't find anything on the web about it.


回答1:


I was facing the same problem with a VS10-addin and found this solution, hope this works for you as well...

    public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
    {
        _applicationObject = (DTE2)application;
        _addInInstance = (AddIn)addInInst;
        // Hook save changes event

        _applicationObject.Events.DocumentEvents.DocumentSaved += DocumentEvents_DocumentSaved;

    }


来源:https://stackoverflow.com/questions/9947955/c-sharp-visual-studio-add-in-detect-when-saving-document

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!