Share via


ProjectItems.AddFromFileCopy-Methode

Kopiert eine Quelldatei und fügt sie dem Projekt hinzu.

Namespace:  EnvDTE
Assembly:  EnvDTE (in EnvDTE.dll)

Syntax

'Declaration
Function AddFromFileCopy ( _
    FilePath As String _
) As ProjectItem
ProjectItem AddFromFileCopy(
    string FilePath
)
ProjectItem^ AddFromFileCopy(
    String^ FilePath
)
abstract AddFromFileCopy : 
        FilePath:string -> ProjectItem 
function AddFromFileCopy(
    FilePath : String
) : ProjectItem

Parameter

  • FilePath
    Typ: System.String
    Erforderlich.Der Pfad und Dateiname des hinzuzufügenden Projektelements.

Rückgabewert

Typ: EnvDTE.ProjectItem
Ein ProjectItem-Objekt.

Hinweise

AddFromFileCopy fügt ein Projektelement aus einer Datei hinzu, das bereits in der Projektverzeichnisstruktur installiert war, oder kopiert es wörtlich, falls notwendig, um es in das Projektverzeichnis zu verschieben.AddFromFileCopy unterscheidet sich von AddFromFile, da es keinen Link hinzufügt, und es unterscheidet sich von AddFromTemplate, da es nicht notwendigerweise die Datei kopiert oder eine Vorlage übernimmt.

Beispiele

Für dieses Beispiel ist Visual Studio .NET 2003 erforderlich.Weitere Informationen finden Sie unter 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

.NET Framework-Sicherheit

Siehe auch

Referenz

ProjectItems Schnittstelle

EnvDTE-Namespace

Weitere Ressourcen

Gewusst wie: Kompilieren und Ausführen der Codebeispiele für das Automatisierungsobjektmodell