共用方式為


_Solution.Open 方法

在指定的檢視中開啟方案。

命名空間:  EnvDTE
組件:  EnvDTE (在 EnvDTE.dll 中)

語法

'宣告
Sub Open ( _
    FileName As String _
)
void Open(
    string FileName
)
void Open(
    [InAttribute] String^ FileName
)
abstract Open : 
        FileName:string -> unit 
function Open(
    FileName : String
)

參數

  • FileName
    型別:System.String
    必要項。要開啟之檔案的檔名。

範例

Sub OpenExample(ByVal dte As DTE2)

    ' Create the full pathname to NewSolution.sln.
    Dim tempPath As String = System.IO.Path.GetTempPath()
    Dim solnName As String = "NewSolution"
    Dim solnPath As String = tempPath & solnName & ".sln"

    ' Try to open NewSolution.sln.
    Try
        dte.Solution.Open(solnPath)
    Catch ex As ArgumentException
        If MsgBox("Solution " & solnPath & " doesn't exist. " & _
            "Create it?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
            ' Create and save NewSolution.sln.
            dte.Solution.Create(tempPath, solnName)
            dte.Solution.SaveAs(solnPath)
        End If
    End Try

End Sub
public void OpenExample(DTE2 dte)
{
    // Create the full pathname to NewSolution.sln.
    string tempPath = System.IO.Path.GetTempPath();
    string solnName = "NewSolution";
    string solnPath = tempPath + solnName + ".sln";

    // Try to open NewSolution.sln.
    try
    {
        dte.Solution.Open(solnPath);
    }
    catch (Exception ex)
    {
        if (MessageBox.Show("Solution " + solnPath + 
            " doesn't exist. " + "Create it?", "", 
            MessageBoxButtons.YesNo) == DialogResult.Yes)
        {
            // Create and save NewSolution.sln.
            dte.Solution.Create(tempPath, solnName);
            dte.Solution.SaveAs(solnPath);
        }
    }
}

.NET Framework 安全性

請參閱

參考

_Solution 介面

EnvDTE 命名空間

其他資源

HOW TO:編譯和執行 Automation 物件模型程式碼範例