VSPackage: File change event for all files

Unanswered VSPackage: File change event for all files

  • 2012年7月10日 2:32
     
     

    I'd like to bind an event to all the files in the project and watch for a change. My problem is that I don't know the file location but it has a specific naming convention. So I would like to check the event for the filename then trigger my code based on that. But right now I only see the IVsFileChangeEx class to use which only supports binding to a specific file.

    Is there any API that supports an event for ANY file that was changed inside or outside of visual studio?

全部回复

  • 2012年7月11日 2:28
     
     

    Hi Mixmasterxp,

    I can't make sence well, you want to change all files no matter their different types? Can you show more detail about your issue?

    I know there are many APIs under the Microsoft.VisualStudio.Shell.Interop, you can find one in it.

    Best regards,

    Disley

  • 2012年7月11日 14:46
     
     

    Hello Disley,

    I do not want to change the files. I want to watch for file changes, so any time a specific file with a name is changed, an event is fired. I'm thinking about just attaching the events by looping through all files in the project.

  • 2012年7月11日 17:24
    版主
     
     

    I do not believe there is a 'any file has changed' event, file change monitoring is generally done per interesting file (where the listener defines interesting).

    Ryan

  • 2012年7月27日 8:26
    版主
     
     

    Hi Shawn,

    Have you any update?

    Best regards,


    Ego [MSFT]
    MSDN Community Support | Feedback to us

  • 2012年8月3日 14:51
     
      包含代码

    You can use EnvDte to do this.

    Subscribe to DocumentsEvents , be sure to keep a local reference to the DocumentsEvents, otherwise the event will not fire.

    private DocumentEvents _documentEvents;
    
    public Constructor(){
     this._documentEvents = this.dte.Events.DocumentEvents;
                this._documentEvents.DocumentSaved += new _dispDocumentEvents_DocumentSavedEventHandler(this.OnDocumentSaved);
    }

    Depends if you can track only when the document is saved. otherwise you need to subscribe to the bufferchanged event (MEF extensibility)