我尝试使用此方法向我的 RichEditBox 添加文件内容:
myRichEditBox.Document.LoadFromStream(Windows.UI.Text.TextSetOptions.None, streamFile);
这就是我填充我的 streamFile 变量的方式:
public static async void openFileAsync(string pathFolder, string file)
{
Windows.Storage.StorageFolder folder = await Windows.Storage.StorageFolder.GetFolderFromPathAsync(pathFolder);
System.Diagnostics.Debug.WriteLine("folder : " + folder.Path);
Windows.Storage.StorageFile fileOpen = await folder.GetFileAsync(file);
System.Diagnostics.Debug.WriteLine("file : " + fileOpen.Path);
Windows.Storage.Streams.IRandomAccessStream stream = await fileOpen.OpenAsync(Windows.Storage.FileAccessMode.Read);
streamFile = stream;
}
我也不例外,但richBoxEdit 文本不可读(字符不可读)。我想阅读txt文件。
预先感谢您的帮助。