Click here to Skip to main content
15,947,389 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
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.

What I have tried:

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?

1 solution

The first question is why are you even doing this? VS allows you to add any file type to any folder for good reasons.

You cannot modify the behavior of Add Existing Item. In the VS implementation, the items has already been "validated", because, well, you're allowed to add any item you want at any time to any folder.

The event you're using is also tagged
This API supports the product infrastructure and is not intended to be used directly from your code.

Microsoft Internal Use Only.
There is no event that fires before the items are added, nor after they after they are selected.

If you're trying to add specific file types from the interface, you're going to have to supply your own menu item outside of "Add Existing Items", complete with your own OpenFile dialog and code to filter specific items.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900