[英]Move ProjectItem to physical directory in custom wizard for Item Template in VS2012
In Visual Studio 2012 (or below, preferably), is it possible to direct a newly created item to a particular folder in the filesystem instead of it going directly to the project root with a project item template? 在Visual Studio 2012(或以下版本,优选)中,是否可以将新创建的项目直接定向到文件系统中的特定文件夹,而不是使用项目项目模板直接将其创建到项目根目录?
The ProjectItem.Save()
and SaveAs()
methods throw an unimplemented exception. ProjectItem.Save()
和SaveAs()
方法将引发未实现的异常。
The short answer is no: you can't direct a file to a subfolder of your project using a vstemplate alone. 简短的答案是:不能仅使用vstemplate将文件定向到项目的子文件夹。
If you don't mind writing a VS extension, you could try this approach which will create the file in the desired subfolder by replacing the "Add New Item" command in Solution Explorer with your own implementation: 如果您不介意编写VS扩展名,则可以尝试以下方法,该方法将用自己的实现替换“解决方案资源管理器”中的“添加新项”命令,从而在所需的子文件夹中创建文件:
The downside to this approach is that every new project item will be added to the project subfolder. 这种方法的缺点是,每个新项目都将添加到项目子文件夹中。 To avoid this, you could add a new context menu command to the Solution Explorer instead of overriding "Add New Item". 为了避免这种情况,您可以向解决方案资源管理器中添加新的上下文菜单命令,而不是覆盖“添加新项”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.