Compartilhar via


Solution2.SaveAs(String) Method

Definition

Saves the solution.

public:
 void SaveAs(System::String ^ FileName);
public:
 void SaveAs(Platform::String ^ FileName);
void SaveAs(std::wstring const & FileName);
[System.Runtime.InteropServices.DispId(14)]
public void SaveAs (string FileName);
[<System.Runtime.InteropServices.DispId(14)>]
abstract member SaveAs : string -> unit
Public Sub SaveAs (FileName As String)

Parameters

FileName
String

Required. The file name in which to save the solution. If the file exists, it is overwritten.

Implements

Attributes

Examples

Sub SaveAsExample(ByVal dte As DTE2)  
    ' Creates a solution and then saves it.  
    ' Create the full path to NewSolution.sln.  
    Dim tempPath As String = System.IO.Path.GetTempPath()  
    Dim solnName As String = "NewSolution"  
    Dim solnPath As String = tempPath & solnName & ".sln"  
    Dim soln As Solution2 = _  
    CType(_applicationObject.Solution, Solution2)  

    Try  

        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  
    Catch ex As SystemException  
        MsgBox("ERROR: " & ex.ToString())  
    End Try  

End Sub  
using System.Windows.Forms;  
public void SolnSaveAsExample(DTE2 dte)  
{  
    // Creates a solution and saves it.  
    string tempPath = System.IO.Path.GetTempPath();  
    string solnName = "NewSolution";  
    string solnPath = tempPath + solnName + ".sln";  
    Solution2 soln = (Solution2)_applicationObject.Solution;  

    try  
    {  
        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);  
        }  
    }  
    catch (SystemException ex)  
    {  
        MessageBox.Show("ERROR: " + ex);  
    }  
}  

Remarks

SaveAs saves the solution with the specified file name.

Applies to