Partilhar via


ITextDocument.SaveAs Method

Definition

Overloads

SaveAs(String, Boolean)

Saves the contents of the TextBuffer to the given filePath. If the save operation is successful, FilePath is set to filePath, and IsDirty is set to false. If the save operation fails, FilePath and IsDirty remains unchanged.

SaveAs(String, Boolean, IContentType)

Saves the contents of the TextBuffer to the given filePath. 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.

SaveAs(String, Boolean, Boolean)

Saves the contents of the TextBuffer to the given filePath. If the save operation is successful, FilePath is set to filePath, and IsDirty is set to false. If the save operation fails, FilePath and IsDirty remains unchanged.

SaveAs(String, Boolean, Boolean, IContentType)

Saves the contents of the TextBuffer to the given filePath. 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.

SaveAs(String, Boolean)

Saves the contents of the TextBuffer to the given filePath. If the save operation is successful, FilePath is set to filePath, and IsDirty is set to false. If the save operation fails, FilePath and IsDirty remains unchanged.

public:
 void SaveAs(System::String ^ filePath, bool overwrite);
public:
 void SaveAs(Platform::String ^ filePath, bool overwrite);
void SaveAs(std::wstring const & filePath, bool overwrite);
public void SaveAs (string filePath, bool overwrite);
abstract member SaveAs : string * bool -> unit
Public Sub SaveAs (filePath As String, overwrite As Boolean)

Parameters

filePath
String

The name of the new file.

overwrite
Boolean

true if filePath should be overwritten if it exists, otherwise false.

Exceptions

filePath is null.

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

An access error occurred during file save.

This object has been disposed.

This object is in the middle of raising events.

Remarks

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

Applies to

SaveAs(String, Boolean, IContentType)

Saves the contents of the TextBuffer to the given filePath. 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.

public:
 void SaveAs(System::String ^ filePath, bool overwrite, Microsoft::VisualStudio::Utilities::IContentType ^ newContentType);
public:
 void SaveAs(Platform::String ^ filePath, bool overwrite, Microsoft::VisualStudio::Utilities::IContentType ^ newContentType);
void SaveAs(std::wstring const & filePath, bool overwrite, Microsoft::VisualStudio::Utilities::IContentType const & newContentType);
public void SaveAs (string filePath, bool overwrite, Microsoft.VisualStudio.Utilities.IContentType newContentType);
abstract member SaveAs : string * bool * Microsoft.VisualStudio.Utilities.IContentType -> unit
Public Sub SaveAs (filePath As String, overwrite As Boolean, newContentType As IContentType)

Parameters

filePath
String

The name of the new file.

overwrite
Boolean

true if filePath should be overwritten if it exists, otherwise false.

newContentType
IContentType

The new IContentType.

Exceptions

filePath or newContentType is null.

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

An access error occurred during file save.

This object has been disposed.

This object is in the middle of raising events.

Remarks

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

Applies to

SaveAs(String, Boolean, Boolean)

Saves the contents of the TextBuffer to the given filePath. If the save operation is successful, FilePath is set to filePath, and IsDirty is set to false. If the save operation fails, FilePath and IsDirty remains unchanged.

public:
 void SaveAs(System::String ^ filePath, bool overwrite, bool createFolder);
public:
 void SaveAs(Platform::String ^ filePath, bool overwrite, bool createFolder);
void SaveAs(std::wstring const & filePath, bool overwrite, bool createFolder);
public void SaveAs (string filePath, bool overwrite, bool createFolder);
abstract member SaveAs : string * bool * bool -> unit
Public Sub SaveAs (filePath As String, overwrite As Boolean, createFolder As Boolean)

Parameters

filePath
String

The name of the new file.

overwrite
Boolean

true if filePath should be overwritten if it exists, otherwise false.

createFolder
Boolean

true if the folder containing filePath should be created if it does not exist, otherwise false.

Exceptions

filePath is null.

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

An access error occurred during file save.

This object has been disposed.

This object is in the middle of raising events.

Remarks

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

Applies to

SaveAs(String, Boolean, Boolean, IContentType)

Saves the contents of the TextBuffer to the given filePath. 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.

public:
 void SaveAs(System::String ^ filePath, bool overwrite, bool createFolder, Microsoft::VisualStudio::Utilities::IContentType ^ newContentType);
public:
 void SaveAs(Platform::String ^ filePath, bool overwrite, bool createFolder, Microsoft::VisualStudio::Utilities::IContentType ^ newContentType);
void SaveAs(std::wstring const & filePath, bool overwrite, bool createFolder, Microsoft::VisualStudio::Utilities::IContentType const & newContentType);
public void SaveAs (string filePath, bool overwrite, bool createFolder, Microsoft.VisualStudio.Utilities.IContentType newContentType);
abstract member SaveAs : string * bool * bool * Microsoft.VisualStudio.Utilities.IContentType -> unit
Public Sub SaveAs (filePath As String, overwrite As Boolean, createFolder As Boolean, newContentType As IContentType)

Parameters

filePath
String

The name of the new file.

overwrite
Boolean

true if filePath should be overwritten if it exists, otherwise false.

createFolder
Boolean

true if the folder containing filePath should be created if it does not exist, otherwise false.

newContentType
IContentType

The new IContentType.

Exceptions

filePath or newContentType is null.

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

An access error occurred during file save.

This object has been disposed.

This object is in the middle of raising events.

Remarks

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

Applies to