我正在开发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);更多推荐
如何以编程方式将文件添加到解决方案?
发布评论