ProjectItems::AddFromFile Method (String^)
Visual Studio 2015
Adds a project item from a file that is installed in a project directory structure.
Assembly: EnvDTE (in EnvDTE.dll)
Parameters
- FileName
-
Type:
System::String^
Required. The file name of the item to add as a project item.
AddFromFile fails if the file to be added is already in the project.
FileName need not contain a full path as long as the file can be found. How a file is found depends on the programming language. In order to use pathless files in Visual Basic and Visual C#, for example, the files must be in the same directory as the project. If they are not, they are copied over. Visual C++ allows linking to files anywhere on the system.
Sub AddFromFileExample(app As DTE) ' This function creates a solution and adds a Visual Basic Console ' project to it. Dim soln As Solution Dim proj As Project Dim projitems As ProjectItems ' Create a reference to the solution. soln = app.Solution ' Create a new solution. soln.Create("c:\temp2", "MyNewSolution") ' Create a new Visual Basic Console application project. ' Adjust the save path as needed. proj = soln.AddFromTemplate("C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\ImportProjects\VB\ImportConsoleApplication.vbproj", "c:\temp2", "My New Project", True) projitems = proj.ProjectItems ' Add a project item from a file. projitems.AddFromFile("C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\NewFileItems\vbclass.vb") End Sub
Show: