VSPackage: File change event for all files
-
terça-feira, 10 de julho de 2012 02: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?
Todas as Respostas
-
quarta-feira, 11 de julho de 2012 02: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
-
quarta-feira, 11 de julho de 2012 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.
-
quarta-feira, 11 de julho de 2012 17:24Moderador
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
-
sexta-feira, 27 de julho de 2012 08:26Moderador
-
sexta-feira, 3 de agosto de 2012 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)

