Share via


ITextDocumentFactoryService2.CreateAndLoadTextDocument 方法

定义

创建一个 , ITextDocument 用于打开 ,并将 的内容 filePath 加载到新的 ITextBuffer中。

public:
 Microsoft::VisualStudio::Text::ITextDocument ^ CreateAndLoadTextDocument(System::String ^ filePath, Microsoft::VisualStudio::Utilities::IContentType ^ contentType, bool attemptUtf8Detection, bool allowCompressedStorage, bool throwOnInvalidCharactersIfUnknownEncoding, [Runtime::InteropServices::Out] bool % characterSubstitutionsOccurred);
public Microsoft.VisualStudio.Text.ITextDocument CreateAndLoadTextDocument (string filePath, Microsoft.VisualStudio.Utilities.IContentType contentType, bool attemptUtf8Detection, bool allowCompressedStorage, bool throwOnInvalidCharactersIfUnknownEncoding, out bool characterSubstitutionsOccurred);
abstract member CreateAndLoadTextDocument : string * Microsoft.VisualStudio.Utilities.IContentType * bool * bool * bool * bool -> Microsoft.VisualStudio.Text.ITextDocument
Public Function CreateAndLoadTextDocument (filePath As String, contentType As IContentType, attemptUtf8Detection As Boolean, allowCompressedStorage As Boolean, throwOnInvalidCharactersIfUnknownEncoding As Boolean, ByRef characterSubstitutionsOccurred As Boolean) As ITextDocument

参数

filePath
String

要加载的文件的完整路径。

attemptUtf8Detection
Boolean

是否尝试将文档加载为 UTF-8 文件。

allowCompressedStorage
Boolean

允许将大型文件存储在压缩缓冲区中。 已弃用:无论传递的值如何,在内部 true 使用。

throwOnInvalidCharactersIfUnknownEncoding
Boolean

如果遇到无效字符,并且没有明确定义的编码,则引发异常。

characterSubstitutionsOccurred
Boolean

如果无法使用给定编码直接转换某些文件字节,则设置为 true。

返回

ITextDocument

例外

filePathcontentType 为 null。

适用于