Udostępnij za pośrednictwem


Solution2.IsOpen Property

Definition

Gets a value which indicates whether a solution is open.

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

Property Value

true if a solution is open; otherwise, false.

Implements

Attributes

Examples

Sub IsOpenExample(ByVal dte As DTE2)  
    ' Displays the IsOpen status of the solution.  
    ' Open a solution in   
    ' Visual Studio before running this example.  
    Try  
        Dim soln As Solution2 = CType _  
        (_applicationObject.Solution, Solution2)  
        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  
//you will need to add this reference to your project as well  
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  
    {  
        Solution2 soln = (Solution2)_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);  
    }  
}  

Remarks

An open solution does not necessarily have a solution (.sln) file, because it might not have been saved yet.

Applies to