VSPackage: File change event for all files
-
Tuesday, July 10, 2012 2:32 AM
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?
All Replies
-
Wednesday, July 11, 2012 2:28 AM
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
-
Wednesday, July 11, 2012 2:46 PM
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.
-
Wednesday, July 11, 2012 5:24 PMModerator
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
-
Friday, July 27, 2012 8:26 AMModerator
-
Friday, August 03, 2012 2:51 PM
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)

