共用方式為


ITextDocument Interface

Definition

Represents a document in the file system that persists an ITextBuffer.

public interface class ITextDocument : IDisposable
public interface ITextDocument : IDisposable
type ITextDocument = interface
    interface IDisposable
Public Interface ITextDocument
Implements IDisposable
Implements

Properties

Encoding

Gets or sets the encoding of the document when saved to disk.

FilePath

The name and path of the file.

IsDirty

Determines whether the ITextBuffer is dirty.

IsReloading

Determines whether the document is currently being reloaded.

LastContentModifiedTime

Gets the last DateTime a change was made to the contents of the document. If it has not been modified since it was loaded or reloaded from disk, this will be the last write time of the underlying file at the time the load or reload occurred; otherwise, it is the last time the contents of the text buffer were changed.

LastSavedTime

Gets the last DateTime the file was saved. This time exactly matches the last file written time on the file system.

TextBuffer

Gets the ITextBuffer containing the document. This value is always non-null.

Methods

Reload()

Reloads the contents of FilePath into TextBuffer.
If the load fails, the contents of the ITextBuffer remains unchanged.

Reload(EditOptions)

Reloads the contents of FilePath into TextBuffer, using the given EditOptions.
If the load fails, the contents of the ITextBuffer remains unchanged.

Rename(String)

Rename the document to the given new file path.

Save()

Saves the contents of the TextBuffer to FilePath.
If the save operation fails, the value of 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, 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)

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.

SaveCopy(String, Boolean, Boolean)

Saves the contents of the TextBuffer to the given filePath.

SaveCopy(String, Boolean)

Saves the contents of the TextBuffer to the given filePath.

SetEncoderFallback(EncoderFallback)

Change the encoder fallback of Encoding.

UpdateDirtyState(Boolean, DateTime)

Updates the IsDirty and LastContentModifiedTime properties.

Events

DirtyStateChanged

Occurs when the value of IsDirty changes. You may not call UpdateDirtyState(Boolean, DateTime) in order to change the IsDirty property while handling this event.

EncodingChanged

Occurs when the Encoding property changes.

FileActionOccurred

Occurs when the document has been loaded from or saved to disk.
You may not call Reload/Save/SaveAs to perform another file action while handling this event.

Applies to