Aracılığıyla paylaş


Project.Save Yöntem

Proje ya da proje öğesi kaydeder.

Ad alanı:  EnvDTE
Derleme:  EnvDTE (EnvDTE.dll içinde)

Sözdizimi

'Bildirim
Sub Save ( _
    FileName As String _
)
void Save(
    string FileName
)
void Save(
    String^ FileName
)
abstract Save : 
        FileName:string -> unit 
function Save(
    FileName : String
)

Parametreler

  • FileName
    Tür: System.String
    İsteğe Bağlı.Proje ya da proje öğesi kaydedileceği adı.

Açıklamalar

FileName Yazılamıyor, ne zaman disk dolu veya gibi var olan yazma izni sorunları, sonra Save üreten bir hata. Dosyayı temel alan yeni bir adla kaydedilen FileName.

Önemli   Savekaydedildikten sonra belgeyi kapatır. Nesneyi yeniden açıncaya veya yeniden kullanılırsa re-initialized gerekecektir.

Örnekler

Bu örnek, yalnızca Visual Studio ile çalışır.net 2003 ve sonraki sürümleri. Daha fazla bilgi için bkz. Nasıl Yapılır: Program aracılığıyla Projeler oluşturmak.

Sub SaveExample(ByVal dte As DTE)

    ' NOTE: This example requires a reference to the 
    '       VSLangProj namespace.

    ' Create a new solution.
    Dim soln As Solution = dte.Solution
    Dim solnName As String = "NewSolution.sln"
    Dim tempPath As String = System.IO.Path.GetTempPath()
    soln.Create(tempPath, solnName)

    ' Create a new Visual Basic Console Application project.
    Dim templatePath As String = dte.Solution.TemplatePath( _
        PrjKind.prjKindVBProject)
    templatePath &= "ConsoleApplication.vsz"
    Dim projName As String = "NewProject"
    soln.AddFromTemplate(templatePath, tempPath & projName, projName)
    Dim proj As Project = soln.Item(1)

    ' Add a new class to the project.
    templatePath = dte.Solution.ProjectItemsTemplatePath( _
        PrjKind.prjKindVBProject)
    templatePath &= "\Class.vsz"
    Dim projItemName As String = "NewClass.vb"
    Dim projItem As ProjectItem = proj.ProjectItems.AddFromTemplate( _
        templatePath, projItemName)

    ' Add an Imports statement to the class file.
    Dim sel As TextSelection = _
        CType(projItem.Document.Selection, TextSelection)
    sel.StartOfDocument()
    sel.Insert("Imports System.Collections" & vbCrLf & vbCrLf, _
        vsInsertFlags.vsInsertFlagsCollapseToStart)

    ' Save the project item, project, and solution.
    projItem.Save()
    proj.Save(proj.FullName)
    soln.SaveAs(tempPath & solnName)

End Sub
public void SaveExample(DTE dte)
{
    // NOTE: This example requires a reference to the 
    //       VSLangProj namespace.

    // Create a new solution.
    Solution soln = dte.Solution;
    string solnName = "NewSolution.sln";
    string tempPath = System.IO.Path.GetTempPath();
    soln.Create(tempPath, solnName);

    // Create a new C# Console Application project.
    string templatePath = 
        dte.Solution.get_TemplatePath(PrjKind.prjKindCSharpProject);
    templatePath += "CSharpConsole.vsz";
    string projName = "NewProject";
    soln.AddFromTemplate(templatePath, tempPath + projName, 
        projName, false);
    Project proj = soln.Item(1);

    // Add a new class to the project.
    templatePath = dte.Solution.ProjectItemsTemplatePath(
        PrjKind.prjKindCSharpProject);
    templatePath += @"\CSharpAddClassWiz.vsz";
    string projItemName = "NewClass.cs";
    ProjectItem projItem = proj.ProjectItems.AddFromTemplate(
        templatePath, projItemName);

    // Add a using statement to the class file.
    TextSelection sel = (TextSelection)projItem.Document.Selection;
    sel.StartOfDocument(false);
    sel.Insert("using System.Collections;" + Environment.NewLine, 
        (int)vsInsertFlags.vsInsertFlagsCollapseToStart);

    // Save the project item, project, and solution.
    projItem.Save("");
    proj.Save(proj.FullName);
    soln.SaveAs(tempPath + solnName);
}

.NET Framework Güvenliği

Ayrıca bkz.

Başvuru

Project Arabirim

EnvDTE Ad Alanı

Diğer Kaynaklar

Nasıl Yapılır: derlemek ve otomasyon nesne modeli kod örnekleri çalıştırma