Share via


Solution2.SaveAs 메서드

솔루션을 저장합니다.

네임스페이스:  EnvDTE80
어셈블리:  EnvDTE80(EnvDTE80.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
    형식: String

    필수 요소. 솔루션을 저장할 파일 이름입니다. 해당 파일이 있으면 덮어씁니다.

설명

SaveAs는 지정된 파일 이름으로 솔루션을 저장합니다.

예제

이 추가 기능 코드를 실행하는 방법에 대한 내용은 방법: 자동화 개체 모델 코드의 예제 컴파일 및 실행을 참조하십시오.

다음 예제에서는 솔루션을 만들고 저장하는 방법을 보여 줍니다.

Public Sub OnConnection(ByVal application As Object, _
 ByVal connectMode As ext_ConnectMode, ByVal addInInst As Object, _
 ByRef custom As Array) Implements IDTExtensibility2.OnConnection
    _applicationObject = CType(application, DTE2)
    _addInInstance = CType(addInInst, AddIn)
    SaveAsExample(_applicationObject)
End Sub

Sub SaveAsExample(ByVal dte As DTE2)
    ' This add-in 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 OnConnection(object application,
 Extensibility.ext_ConnectMode connectMode, object addInInst,
 ref System.Array custom)
{
    _applicationObject = (DTE2)application;
    _addInInstance = (AddIn)addInInst;
    // Pass the applicationObject member variable to the code example.
    SolnSaveAsExample((DTE2)_applicationObject);
}

public void SolnSaveAsExample(DTE2 dte)
{
    // This add-in 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);
    }
}

.NET Framework 보안

참고 항목

참조

Solution2 인터페이스

EnvDTE80 네임스페이스

기타 리소스

방법: 자동화 개체 모델 코드의 예제 컴파일 및 실행