_Solution.SaveAs 方法

保存解决方案。

命名空间:  EnvDTE
程序集:  EnvDTE(在 EnvDTE.dll 中)

语法

声明
Sub SaveAs ( _
    FileName As String _
)
void SaveAs(
    string FileName
)
void SaveAs(
    [InAttribute] String^ FileName
)
abstract SaveAs : 
        FileName:string -> unit 
function SaveAs(
    FileName : String
)

参数

  • FileName
    类型:System.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);
        }
    }
}

.NET Framework 安全性

请参见

参考

_Solution 接口

EnvDTE 命名空间

其他资源

如何:编译和运行自动化对象模型代码示例