_Solution.SaveAs(String) 方法

定义

保存解决方案。

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)

参数

FileName
String

必需。 保存解决方案的文件名。 如果该文件存在,它会被覆盖。

属性

示例

Sub SaveAsExample(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 SaveAsExample(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);  
        }  
    }  
}  

注解

用指定的文件名保存解决方案。

适用于