0

I have to save files from folder on skdrive to my isolated storage (if files in isolated storage exist then override them).

This is my code:

    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?
    }

How can I save files in method liveClient_DownloadCompleted?

Earlgray
  • 647
  • 1
  • 8
  • 31

1 Answers1

1

I find solution:

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();
        }
    }
}
Earlgray
  • 647
  • 1
  • 8
  • 31