Solution4.AddFromFile(String, Boolean) Méthode
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Ajoute un projet à la solution qui est basée sur un fichier projet déjà stocké dans le système.
EnvDTE::Project AddFromFile(std::wstring const & FileName, bool Exclusive = true);
[System.Runtime.InteropServices.DispId(16)]
public EnvDTE.Project AddFromFile (string FileName, bool Exclusive = true);
[<System.Runtime.InteropServices.DispId(16)>]
abstract member AddFromFile : string * bool -> EnvDTE.Project
Public Function AddFromFile (FileName As String, Optional Exclusive As Boolean = true) As Project
Paramètres
- FileName
- String
Obligatoire. Chemin d'accès complet et nom de fichier du fichier projet.
- Exclusive
- Boolean
Facultatif. Indique si le projet se charge dans la solution en cours ou dans sa propre solution ; true si la solution en cours est fermée et que le projet est ajouté à une nouvelle solution, false si le projet est ajouté à une solution ouverte existante.
Retours
Objet Project.
Implémente
- Attributs
Exemples
Sub AddFromFileExample(ByVal dte As DTE2)
' Creates a solution and add an existing project to it.
Try
Dim soln As Solution4 = _
CType(_applicationObject.Solution, Solution4)
' Create a new solution.
' Make sure the path below exists on your computer.
' You can modify the path.
soln.Create("c:\temp2", "MyNewSolution")
' Add an existing project to the new solution.
' Modify the path to a location that contains a
' Visual Studio project.
soln.AddFromFile _
("<default project location>\Visual Studio 2005\ _
Projects\ConsoleApplication\ConsoleApplication\ _
ConsoleApplication.csproj")
Catch ex As System.Exception
MsgBox(ex.ToString)
End Try
End Sub
public void AddFromFileExample(DTE2 dte)
{
// Create a solution and add an existing project to it.
try
{
Solution4 soln = (Solution4)_applicationObject.Solution;
// Create a solution.
// Make sure that the file path specified below
// exists on your computer.
// You can modify the path.
soln.Create("c:\temp2", "MyNewSolution");
// Add an existing project to the new solution.
// Modify the path to a location that contains
// a Visual Studio project.
soln.AddFromFile(@"<default project location>
\Visual Studio 2005\Projects\ConsoleApplication
\ConsoleApplication\ ConsoleApplication.csproj", true);
}
catch(SystemException ex)
{
MessageBox.Show("ERROR: " + ex);
}
}
Remarques
Vous pouvez utiliser la LaunchWizard méthode au lieu AddFromFile d’exécuter un Assistant si vous souhaitez supprimer son interface utilisateur pendant l’exécution. LaunchWizard possède un paramètre qui vous permet de désactiver l’interface utilisateur.