I am trying to add file type validation in "add existing item" in solution explorer in visual studio experimental instance. If the selected file type is not valid, then it needs to display message box like invalid file type. Else it needs to add the file to the project.
Currently by using this "VS.Events.ProjectItemsEvents.AfterAddProjectItems", it is adding the file before validating file type.
Is there any visual studio event to call at the time of "add existing Item" to validate?
I am afraid that there is not a specific Visual Studio event that fires before items are added during the "Add Existing Item" process.
If you want to validate file type before adding files to projects/solution,here is a workaround:
you can implement your custom validation logic by creating a separate menu like "validate file type".
1.Create a custom menu item in your extension.
https://learn.microsoft.com/en-us/visualstudio/extensibility/creating-an-extension-with-a-menu-command?view=vs-2022
2.Validate the file type based on its file type. If the file type is invalid, show a message box with an appropriate error message. Otherwise, add the file to the project programmatically.
Hope it can help you.