共用方式為


Document.Save(String) Method

Definition

Saves the document.

EnvDTE::vsSaveStatus Save(std::wstring const & FileName = "");
[System.Runtime.InteropServices.DispId(129)]
public EnvDTE.vsSaveStatus Save (string FileName = "");
[<System.Runtime.InteropServices.DispId(129)>]
abstract member Save : string -> EnvDTE.vsSaveStatus
Public Function Save (Optional FileName As String = "") As vsSaveStatus

Parameters

FileName
String

Optional. The name in which to save the document. Defaults to the path associated with this document. That is, if an empty string is passed, the document is saved with its current name.

Returns

A vsSaveStatus constant indicating whether or not the save was successful.

Attributes

Examples

Sub SaveExample()  
    Dim objDoc As Document  
    ' Create a new text file.  
    DTE.ItemOperations.NewFile("General\Text File")  
    ' Create a document reference.  
    objDoc = DTE.Documents.Item(1)  
    ' Save the new text file.  
    objDoc.Save("c:\temp\mynewdoc.txt")  
End Sub  

Remarks

If FileName cannot be written, such as when the disk is full or there are write permission problems, then Save produces an error. The file is saved with a new name based on FileName.

The FileName parameter is optional in Visual Studio 2010, but not optional in Visual Studio 2008.

Applies to