Solution3.AddSolutionFolder 方法
将解决方案文件夹添加到 ProjectItems 集合中。
命名空间: EnvDTE90
程序集: EnvDTE90(在 EnvDTE90.dll 中)
语法
声明
Function AddSolutionFolder ( _
Name As String _
) As Project
Project AddSolutionFolder(
string Name
)
Project^ AddSolutionFolder(
String^ Name
)
abstract AddSolutionFolder :
Name:string -> Project
function AddSolutionFolder(
Name : String
) : Project
参数
Name
类型:String解决方案文件夹的名称。
返回值
类型:Project
一个 Project 对象。
备注
AddSolutionFolder 返回 SolutionFolder 对象,该对象可强制转换或使用查询接口 (QI) 转换为 Project 对象。
示例
有关如何运行此外接程序代码的信息,请参见如何:编译和运行自动化对象模型代码示例。
Public Sub OnConnection(ByVal application As Object, _
ByVal connectMode As ext_ConnectMode, ByVal addInInst As Object, _
ByRef custom As Array) Implements IDTExtensibility2.OnConnection
_applicationObject = CType(application, DTE2)
_addInInstance = CType(addInInst, AddIn)
SolnFolderExample(_applicationObject)
End Sub
Sub SolnFolderExample(ByVal dte As DTE2)
' This add-in adds a new folder to an existing solution.
Try
Dim soln As Solution3 = _
CType(_applicationObject.Solution, Solution3)
Dim solnName As String = _
System.IO.Path.GetFileNameWithoutExtension(soln.FullName)
MsgBox("Adding a new folder to " & solnName)
soln.AddSolutionFolder("MynewFolder")
Catch ex As System.Exception
MsgBox(ex.ToString)
End Try
End Sub
using System.Windows.Forms;
public void OnConnection(object application,
Extensibility.ext_ConnectMode connectMode, object addInInst,
ref System.Array custom)
{
_applicationObject = (DTE2)application;
_addInInstance = (AddIn)addInInst;
// Pass the applicationObject member variable to the code example.
AddSolnFolderExample((DTE2)_applicationObject);
}
public void AddSolnFolderExample(DTE2 dte)
{
// This add-in adds a folder to an existing solution.
// Open a solution in
// Visual Studio before running this example.
try
{
Solution3 soln = (Solution3)_applicationObject.Solution;
string solnName =
System.IO.Path.GetFileNameWithoutExtension(soln.FullName);
MessageBox.Show("Adding a folder to the solution " + solnName);
soln.AddSolutionFolder("MyNewFolder");
}
catch(SystemException ex)
{
MessageBox.Show("ERROR: " + ex);
}
}
.NET Framework 安全性
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关详细信息,请参阅通过部分受信任的代码使用库。