共用方式為


Project.SaveAs 方法

儲存方案、專案或專案項目。

命名空間:  EnvDTE
組件:  EnvDTE (在 EnvDTE.dll 中)

語法

'宣告
Sub SaveAs ( _
    NewFileName As String _
)
void SaveAs(
    string NewFileName
)
void SaveAs(
    [InAttribute] String^ NewFileName
)
abstract SaveAs : 
        NewFileName:string -> unit 
function SaveAs(
    NewFileName : String
)

參數

  • NewFileName
    型別:System.String
    必要項。用來儲存方案、專案或專案項目的檔名。如果檔案已存在,則會覆寫上去。

備註

SaveAs 會以指定的檔名儲存專案項目。

範例

Public Sub CodeExample(ByVal dte As DTE2) 
    Try
        ' Open a project before running this sample.
        Dim prj As Project = dte.Solution.Projects.Item(1)
        Dim prjs As Projects
        
        Dim del As DialogResult
        del = MessageBox.Show("Delete project from solution?", "Delete Method", MessageBoxButtons.YesNo, MessageBoxIcon.Warning)
        If del = DialogResult.Yes Then
            prj.Delete()
        End If
        del = MessageBox.Show("Save project as another filename?", "SaveAs Method", MessageBoxButtons.YesNo)
        If del = DialogResult.Yes Then
            prj.SaveAs(Interaction.InputBox("Save this project with new name: ", "SaveAs Method", "MyProjectWithNewName", 300, 300))
        End If
    Catch ex As Exception
        MessageBox.Show(ex.Message)
    End Try
End Sub

[C#]

public void CodeExample(DTE2 dte)
{  
    try
    {   // Open a project before running this sample.
        Project prj = dte.Solution.Projects.Item(1);
        Projects prjs;

        DialogResult del;
        del = MessageBox.Show("Delete project from solution?", "Delete Method", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
        if (del == DialogResult.Yes)
            prj.Delete();
        del = MessageBox.Show("Save project as another filename?", "SaveAs Method", MessageBoxButtons.YesNo);
        if (del == DialogResult.Yes)
        {
            prj.SaveAs(Interaction.InputBox("Save this project with new name: ", "SaveAs Method",
                "MyProjectWithNewName", 300, 300));
        }
    }
    catch(Exception ex)
    {
        MessageBox.Show(ex.Message);
    }
}

.NET Framework 安全性

請參閱

參考

Project 介面

EnvDTE 命名空間

其他資源

HOW TO:編譯和執行 Automation 物件模型程式碼範例