如何附加一个文件,在异步的Windows Phone 8
我想追加到最新的Windows Phone的文件。问题是我想要做异步的一切,我不知道该怎么做。
I'm trying to append to a file in the latest Windows Phone. The problem is i'm trying to do everything asynchronously and i'm not sure how to do it.
private async void writeResult(double lat, double lng)
{
StorageFolder localFolder = ApplicationData.Current.LocalFolder;
StorageFile storageFile = await localFolder.CreateFileAsync("result.txt", CreationCollisionOption.OpenIfExists);
Stream writeStream = await storageFile.OpenStreamForWriteAsync();
using (StreamWriter writer = new StreamWriter(writeStream))
//using (StreamWriter sw = new StreamWriter("result.txt", true))
{
{
await writer.WriteLineAsync(lat + "," + lng);
//await sw.WriteLineAsync(lat + "," + lng);
writer.Close();
//sw.Close();
}
}
}
我有这到目前为止,其写入文件很好,我可以读取它以后大同小异,但它在写我有什么,而不是在新的一行。该注释掉行显示如何去无WP7流,但我不能得到那个工作是(真正的意思是附加标志)和真的应该被无论如何利用新的WP8方法。
I have this so far, which writes to the file fine and I can read it later on much the same, however it writes over what I have instead of on a new line. The commented out lines show how to go about without the stream in WP7, but I can't get that to work either (the true is is the append flag) and really should be utilizing the new WP8 methods anyway.
任何意见AP preciated
Any comments appreciated
我能够通过奥莱Nechytailo使用的建议(Stream.Seek())成功
I was able to use the suggestion ( Stream.Seek() ) by Oleh Nechytailo successfully