Partager via


_Solution.AddFromFile(String, Boolean) Method

Definition

Adds a project to the solution, based on a project file already stored in the system.

EnvDTE::Project AddFromFile(std::wstring const & FileName, bool Exclusive = false);
[System.Runtime.InteropServices.DispId(16)]
public EnvDTE.Project AddFromFile (string FileName, bool Exclusive = false);
[<System.Runtime.InteropServices.DispId(16)>]
abstract member AddFromFile : string * bool -> EnvDTE.Project
Public Function AddFromFile (FileName As String, Optional Exclusive As Boolean = false) As Project

Parameters

FileName
String

Required. The full path and file name of the project file.

Exclusive
Boolean

Optional. Indicates whether the project loads in the current solution or its own; true if the current solution is closed and the project is added to a new solution, false if the project is added to the existing open solution.

Returns

A Project object.

Attributes

Examples

Sub AddFromFileExample()  
   ' This function creates a solution and adds a Visual Basic Console  
   ' project to it.   
   Dim soln As Solution  

   ' Create a reference to the solution.  
   soln = DTE.Solution  

   ' Create a new solution.  
   soln.Create("c:\temp2", "MyNewSolution")  
   ' Add an existing project to the new solution.  
   soln.AddFromFile("c:\temp\SomeProj.vbproj")  
End Sub  

Remarks

You can use the LaunchWizard method rather than AddFromFile to execute a wizard if you want to suppress its UI during execution. LaunchWizard has a parameter that allows you to disable the UI.

Applies to