次の方法で共有


ProjectItems.AddFromDirectory メソッド

ディレクトリから 1 つ以上の ProjectItem オブジェクトを ProjectItems コレクションに追加します。

名前空間:  EnvDTE
アセンブリ:  EnvDTE (EnvDTE.dll 内)

構文

'宣言
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

パラメーター

  • Directory
    型: System.String
    必ず指定します。追加するプロジェクト項目を含むディレクトリ。

戻り値

型: EnvDTE.ProjectItem
ProjectItem オブジェクト。

解説

AddFromDirectory は、指定されたディレクトリとサブディレクトリを順次参照し、すべての項目をプロジェクトに自動的に追加します。これにより、項目を追加する操作を繰り返す手間を省くことができます。

この例は、Visual Studio .NET 2003 でのみ動作します。 詳細については、「方法 : テンプレートを使用してプロジェクトを作成するコードを移行します。」を参照してください。

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 セキュリティ

  • 直前の呼び出し元に対する完全な信頼。 このメンバーは、部分的に信頼されているコードから使用することはできません。 詳細については、「部分信頼コードからのライブラリの使用」を参照してください。

参照

参照

ProjectItems インターフェイス

EnvDTE 名前空間

その他の技術情報

方法 : オートメーション オブジェクト モデルのコード例をコンパイルおよび実行する