| < Free Open Study > |
|
You can add an item to a project through the use of the AddFromFile method of the ProjectItems object. The following code snippet creates a solution, adds aVisual Basic console application, and finally adds a file to the project:
' This function creates a solution and adds a Visual ' Basic .NET Console ' project to it. Dim sln As Solution Dim prj As Project Dim prjitems As ProjectItems ' Create a reference to the solution. sln = DTE.Solution ' Create a new solution. sln.Create("c:\temp2", "TestSolution") ' Create a new VB Console application project. ' Adjust the save path as ' needed. prj = sln.AddFromTemplate( "C:\Program Files\Microsoft Visual Studio .NET\Vb7\VBWizards\ConsoleApplication\Templates\1033\ ConsoleApplication.vbproj", "c:\temp2", "TestProjectt", True) prjitems = prj.ProjectItems ' Add a project item from a file. Prjitems.AddFromFile("C:\temp\Test.bas")
| < Free Open Study > |
|