如何以编程方式将文件添加到解决方案?

编程入门 行业动态 更新时间:2024-10-27 02:29:51
本文介绍了如何以编程方式将文件添加到解决方案?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在开发VS软件包,我需要实现的功能的一部分是向当前打开的解决方案的解决方案项中添加文件.

I am developing a VS Package and part of the functionality that I need to implement is to add a file to the Solution Items of the currently open Solution.

如果您在解决方案"上单击鼠标右键,然后选择添加">现有项",则此操作将与手动执行的操作完全相同.然后选择磁盘上的文件.

This is exactly the same action that would be performed manually if you right-click on a Solution and choose Add > Existing Item. Then selected a file on disk.

我已经很好地了解了DTE和DTE2接口,可以看到添加和操作项目的操作,但是似乎没有用于添加单个文件的任何操作.

I have taken a good look at the DTE and DTE2 interfaces and can see the operations to add and manipulate projects but there doesn't appear to be any operations for adding individual files.

谢谢.

推荐答案

好吧,我意识到我可以只记录一个Macro来捕获操作,然后在VS Macro IDE中检查代码.

Ok, I realised I could just record a Macro to capture the operation then examine the code in the VS Macro IDE.

执行此操作所需的代码是

The code required to do this is.

DTE.ItemOperations.AddExistingItem(filePath);

更多推荐

如何以编程方式将文件添加到解决方案?

本文发布于:2023-11-01 23:34:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1550730.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:解决方案   方式   文件

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!