Поделиться через


ITextDocument.SaveAs Method (String, Boolean, IContentType)

Saves the contents of the TextBuffer to the specified file path.

Namespace:  Microsoft.VisualStudio.Text
Assembly:  Microsoft.VisualStudio.Text.Data (in Microsoft.VisualStudio.Text.Data.dll)

Syntax

'Декларация
Sub SaveAs ( _
    filePath As String, _
    overwrite As Boolean, _
    newContentType As IContentType _
)
void SaveAs(
    string filePath,
    bool overwrite,
    IContentType newContentType
)
void SaveAs(
    String^ filePath, 
    bool overwrite, 
    IContentType^ newContentType
)
abstract SaveAs : 
        filePath:string * 
        overwrite:bool * 
        newContentType:IContentType -> unit 
function SaveAs(
    filePath : String, 
    overwrite : boolean, 
    newContentType : IContentType
)

Parameters

  • overwrite
    Type: System.Boolean
    true if filePath should be overwritten if it exists, otherwise false.

Exceptions

Exception Condition
InvalidOperationException

This object is in the middle of raising events.

ArgumentNullException

filePath or newContentType is nulla null reference (Nothing in Visual Basic).

UnauthorizedAccessException

An access error occurred during file save.

IOException

An I/O error occurred (including an error caused by attempting to overwrite an existing file when overwrite is false).

ObjectDisposedException

This object has been disposed.

Remarks

If the save is successful, FilePath is set to filePath, and IsDirty is set to false. If the save fails, FilePath and IsDirty remains unchanged.

The order of events raised as a result of a successful file SaveAs operation is FileActionOccurred followed by ContentTypeChanged.

.NET Framework Security

See Also

Reference

ITextDocument Interface

SaveAs Overload

Microsoft.VisualStudio.Text Namespace