问题
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