ITextDocument::SaveAs Method (String^, Boolean, Boolean, IContentType^)
Saves the contents of the TextBuffer to the specified file path.
Assembly: Microsoft.VisualStudio.Text.Data (in Microsoft.VisualStudio.Text.Data.dll)
void SaveAs( String^ filePath, bool overwrite, bool createFolder, IContentType^ newContentType )
Parameters
- filePath
-
Type:
System::String^
The name of the new file.
- overwrite
-
Type:
System::Boolean
true if filePath should be overwritten if it exists, otherwise false.
- createFolder
-
Type:
System::Boolean
true if the folder containing filePath should be created if it does not exist, otherwise false.
- newContentType
-
Type:
Microsoft.VisualStudio.Utilities::IContentType^
The new IContentType.
| Exception | Condition |
|---|---|
| InvalidOperationException | This object is in the middle of raising events. |
| ArgumentNullException | filePath or newContentType is null. |
| 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. |
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.