Export (0) Print
Expand All

_Solution.Open Method

Opens the solution in the specified view.

Namespace:  EnvDTE
Assembly:  EnvDTE (in EnvDTE.dll)

void Open(
	string FileName
)

Parameters

FileName
Type: System.String

Required. The filename of the file to open.

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);
        }
    }
}

Show:
© 2015 Microsoft