0
我在WP8中讀取文件時遇到問題。在WP8中讀取文件
string text;
IStorageFolder applicationFolder = ApplicationData.Current.LocalFolder;
IStorageFile storageFile = await applicationFolder.GetFileAsync("MyFile.txt");
IRandomAccessStream accessStream = await storageFile.OpenReadAsync();
using (Stream stream = accessStream.AsStreamForRead((int)accessStream.Size))
{
byte[] content = new byte[stream.Length];
await stream.ReadAsync(content, 0, (int)stream.Length);
text = Encoding.UTF8.GetString(content, 0, content.Length);
}
return text;
有時storagefile
或accessStream
崩潰沒有理由。 如果我調試它們,它的工作原理。
我不知道爲什麼。誰能幫我?
謝謝你,它的工作原理:D –
非常歡迎! – Jieqin