当尝试在 Visual Studio 实验实例的解决方案资源管理器中添加现有项目时,如何添加文件类型验证?

编程


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?

解决方案1

第一个问题是你为什么要这样做? VS 允许您将任何文件类型添加到任何文件夹,这是有充分理由的。

您无法修改“添加现有项目”的行为。 在 VS 实现中,这些项目已经被“验证”,因为您可以随时将所需的任何项目添加到任何文件夹。

您正在使用的事件也已标记

引用:

此 API 支持产品基础架构,并不适合直接从您的代码中使用。

仅供 Microsoft 内部使用。

在添加项目之前或选择项目之后都不会触发任何事件。

如果您尝试从界面添加特定文件类型,则必须在“添加现有项目”之外提供您自己的菜单项,并使用您自己的 OpenFile 对话框和代码来过滤特定项目。

コメント

タイトルとURLをコピーしました