我必须将skdrive文件夹中的文件保存到我的隔离存储中(如果存在隔离存储中的文件,则覆盖它们)。
这是我的代码:
private void RestoreData(LiveConnectClient liveClient, string storedFolderId)
{
liveClient.DownloadCompleted += liveClient_DownloadCompleted;
liveClient.DownloadAsync(storedFolderId + "/content");
}
private void liveClient_DownloadCompleted(object sender, LiveDownloadCompletedEventArgs e)
{
Stream stream = e.Result;
// HOW TO SAVE FILES ON IN THIS METHOD?
}
如何在方法liveClient_DownloadCompleted中保存文件?
答案 0 :(得分:1)
我找到解决方案:
private void liveClient_DownloadCompleted(object sender, LiveDownloadCompletedEventArgs e)
{
Stream stream = e.Result;
using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication())
{
using (IsolatedStorageFileStream fileToSave = storage.OpenFile("tasks.xml", FileMode.Create, FileAccess.ReadWrite))
{
stream.CopyTo(fileToSave);
stream.Flush();
stream.Close();
}
}
}