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.
string fileExtension = Path.GetExtension(fileName).ToLower();
if (Array.IndexOF([".pdf", ".doc", ".docx"],fileExtension) == -1 )
{
// error message
}else{
// add file to project
}
Hope it can help you.
BeforeAddProjectItemsevent or the like?