Compartilhar via


ProjectItems.AddFromFileCopy(String) Method

Definition

Copies a source file and adds it to the project.

public:
 EnvDTE::ProjectItem ^ AddFromFileCopy(System::String ^ FilePath);
public:
 EnvDTE::ProjectItem ^ AddFromFileCopy(Platform::String ^ FilePath);
EnvDTE::ProjectItem AddFromFileCopy(std::wstring const & FilePath);
[System.Runtime.InteropServices.DispId(207)]
public EnvDTE.ProjectItem AddFromFileCopy (string FilePath);
[<System.Runtime.InteropServices.DispId(207)>]
abstract member AddFromFileCopy : string -> EnvDTE.ProjectItem
Public Function AddFromFileCopy (FilePath As String) As ProjectItem

Parameters

FilePath
String

Required. The path and file name of the project item to be added.

Returns

A ProjectItem object.

Attributes

Examples

This example works only in Visual Studio .NET 2003. For more information, see Migrating Code that Creates Projects by Using Templates.

Sub AddFromFileExample()  
   ' 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 = DTE.Solution  

   ' Create a new solution.  
   soln.Create("c:\temp2", "MyNewSolution")  

   ' Create a new VB Console application project. Adjust the save path as   
   ' needed.  
   proj = soln.AddFromTemplate("C:\Program Files\Microsoft Visual Studio .NET\Vb7\VBWizards\ConsoleApplication\Templates\1033\ConsoleApplication.vbproj", "c:\temp2", "My New Project", True)  
   projitems = proj.ProjectItems  

   ' Add a project item from a file.  
   projitems.AddFromFileCopy("C:\temp\somefile.bas")  
End Sub  

Remarks

AddFromFileCopy adds a project item from a file already installed in the project directory structure, or copies it verbatim, if necessary, to move it into the project directory. AddFromFileCopy differs from AddFromFile because it does not add a link, and it differs from AddFromTemplate in that it does not necessarily copy the file or apply a template.

Applies to