Solution4.AddFromFile(String, Boolean) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
向基于已存储在系统中的项目文件的解决方案添加一个项目。
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
参数
- FileName
- String
必需。 项目文件的完整路径及其文件名。
- Exclusive
- Boolean
可选。 指示项目是加载到当前解决方案中还是加载到它自己的解决方案中;如果当前解决方案已关闭,并且项目添加到新的解决方案中,则为 true;如果项目添加到已打开的现有解决方案中,则为 false。
返回
Project 对象。
实现
- 属性
示例
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);
}
}
注解
LaunchWizard AddFromFile 如果要在执行过程中取消其用户界面 (UI) ,可以使用方法而不是执行向导。 LaunchWizard 具有允许您禁用 UI 的参数。