Solution4.IsOpen 属性

定义

获取解决方案是否打开。

public:
 property bool IsOpen { bool get(); };
public:
 property bool IsOpen { bool get(); };
[System.Runtime.InteropServices.DispId(36)]
public bool IsOpen { [System.Runtime.InteropServices.DispId(36)] get; }
[<System.Runtime.InteropServices.DispId(36)>]
[<get: System.Runtime.InteropServices.DispId(36)>]
member this.IsOpen : bool
Public ReadOnly Property IsOpen As Boolean

属性值

Boolean

如果解决方案已打开,则为 true;否则为 false

实现

属性

示例

Sub IsOpenExample(ByVal dte As DTE2)  
    ' Display the IsOpen status of the solution.  
    ' Open a solution in Visual Studio before running this example.  
    Try  
        Dim soln As Solution4 = CType _  
        (_applicationObject.Solution, Solution4)  
        Dim solnName As String = _  
        System.IO.Path.GetFileNameWithoutExtension(soln.FullName)  
        MsgBox("Solution " & solnName & _  
        " has the following IsOpen state:" & _  
        vbCrLf & vbCrLf & soln.IsOpen.ToString())  
    Catch ex As System.Exception  
        MsgBox(ex.ToString)  
    End Try  
End Sub  
using System.Windows.Forms;  
public void IsOpenExample(DTE2 dte)  
{  
    // Determines if a solution is open.   
    // Open a solution in Visual Studio before running this example.  
    try  
    {  
        Solution4 soln = (Solution4)_applicationObject.Solution;  
        string solnName =  
          System.IO.Path.GetFileNameWithoutExtension(soln.FullName);  
        MessageBox.Show("Solution " + solnName + " IsOpen status is: "  
          + soln.IsOpen.ToString());  
    }  
    catch(SystemException ex)  
    {  
        MessageBox.Show("ERROR: " + ex);  
    }  
}  

注解

打开的解决方案不一定有解决方案 ( .sln) 文件,因为它可能尚未保存。

适用于