Freigeben über


ProjectItems.AddFromDirectory-Methode

Fügt der ProjectItems-Auflistung eines oder mehrere ProjectItem-Objekte aus einem Verzeichnis hinzu.

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

Syntax

'Declaration
Function AddFromDirectory ( _
    Directory As String _
) As ProjectItem
ProjectItem AddFromDirectory(
    string Directory
)
ProjectItem^ AddFromDirectory(
    [InAttribute] String^ Directory
)
abstract AddFromDirectory : 
        Directory:string -> ProjectItem
function AddFromDirectory(
    Directory : String
) : ProjectItem

Parameter

  • Directory
    Typ: String

    Erforderlich. Das Verzeichnis, in dem sich das hinzuzufügende Projektelement befindet.

Rückgabewert

Typ: EnvDTE.ProjectItem
Ein ProjectItem-Objekt.

Hinweise

AddFromDirectory nimmt automatisch nacheinander alle Elemente eines angegebenen Verzeichnisses und seiner Unterverzeichnisse in das Projekt auf. Das erspart es Ihnen, die Elemente einzeln mit dem Befehl Element hinzufügen hinzuzufügen.

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 AddFromDirectoryExample()
   ' 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 Visual Basic 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 all of the items in the specified directory (and subdirectories) 
   ' to the project.
   projitems.AddFromDirectory("C:\Program Files\Microsoft Visual Studio .NET\Vb7\VBWizards\ConsoleApplication\Templates\1033")
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