保存 TextBuffer 的内容到指定的文件路径。
命名空间: Microsoft.VisualStudio.Text
程序集: Microsoft.VisualStudio.Text.Data(在 Microsoft.VisualStudio.Text.Data.dll 中)
语法
声明
Sub SaveAs ( _
filePath As String, _
overwrite As Boolean, _
createFolder As Boolean, _
newContentType As IContentType _
)
void SaveAs(
string filePath,
bool overwrite,
bool createFolder,
IContentType newContentType
)
void SaveAs(
String^ filePath,
bool overwrite,
bool createFolder,
IContentType^ newContentType
)
abstract SaveAs :
filePath:string *
overwrite:bool *
createFolder:bool *
newContentType:IContentType -> unit
function SaveAs(
filePath : String,
overwrite : boolean,
createFolder : boolean,
newContentType : IContentType
)
参数
filePath
类型:String新文件的名称。
overwrite
类型:Boolean如果在 filePath 存在的情况下应覆盖它,则为 true;否则为 false。
createFolder
类型:Boolean如果在包含 filePath 的文件夹不存在的情况下应创建它,则为 true;否则为 false。
newContentType
类型:Microsoft.VisualStudio.Utilities.IContentType新的 IContentType。
异常
异常 | 条件 |
---|---|
InvalidOperationException | 此对象是在引发事件元。 |
ArgumentNullException | filePath 或 newContentType 为 nullnull 引用(在 Visual Basic 中为 Nothing)。 |
UnauthorizedAccessException | 在保存的文件中,访问错误。 |
IOException | I/O 错误时 (尝试导致的错误包括复盖现有文件,并且 overwrite 是 false时)。 |
ObjectDisposedException | 此对象已被释放。 |
备注
如果保存成功, FilePath 设置为 filePath,并且, IsDirty 设置为 false。 如果保存失败, FilePath 和 IsDirty 不变。
由于成功的文件 SaveAs 操作引发的事件顺序是 ContentTypeChanged执行的 FileActionOccurred 。
.NET Framework 安全性
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关详细信息,请参阅通过部分受信任的代码使用库。