windows phone 8 异步访问独立存储区
2014-09-11 15:19
330 查看
StorageFile storageFile = await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(new Uri("msappdata:///local/CaptainsLog.store ")); Stream readStream = await StorageFile.OpenStreamForReadAsync(); using (StreamReader reader = new StreamReader(readStream)) { theData = await reader.ReadToEndAsync(); }
public static async Task SaveLogFile(string logData)
{
Debug.WriteLine(logData);
try
{
logFolder = await ApplicationData.Current.LocalFolder.CreateFolderAsync(SysLog.LOGFOLDERNAME, CreationCollisionOption.OpenIfExists);
string logFileName = GenerateLogFileName();
logFile = await logFolder.CreateFileAsync(logFileName, CreationCollisionOption.OpenIfExists);
}
using (IRandomAccessStream outStream = await logFile.OpenAsync(FileAccessMode.ReadWrite))
{
Stream s = outStream.AsStreamForWrite();
s.Seek(0, SeekOrigin.End);
byte[] readBuffer = Encoding.UTF8.GetBytes(logData + "\r\n");
await s.WriteAsync(readBuffer, 0, readBuffer.Length);
await s.FlushAsync();
}
}
catch (Exception ex)
{
Log("SaveLogFile Error", ex.Message);
}
}
相关文章推荐
- Windows Phone 8安装包中的文件和独立存储区中的文件访问
- Windows Phone 7 独立存储Isolated Storage
- 针对 Windows Phone 7 上的独立存储的 Sterling
- Windows Phone开发之独立存储二
- windows phone:独立存储
- Windows Phone 8的独立存储文件系统
- Windows Phone 7程序独立存储空间容量测试
- windows phone 独立存储空间的操作(2)[转]
- Windows Phone 独立存储之IsolatedStorageFile
- windows phone 独立存储空间的操作
- Windows Phone 之独立存储
- Windows Phone 31 日谈——第15日:独立存储
- Windows Phone 7(WP7)开发工具 查看独立存储空间中数据库内容
- Windows Phone开发之路(18) 独立存储
- Windows Phone开发之独立存储、文件的读写、ListBox绑定数据、NavigationService实现XAML跳转
- windows phone 独立存储空间的操作 (2)
- Windows Phone 7 独立存储Isolated Storage
- Windows Phone 7独立存储空间IsolatedStorage
- Windows Phone 独立存储之IsolatedStorageFile
- Windows Phone实用开发技巧(39):WebBrowser引用独立存储空间中的图片