簡體   English   中英

WP7-如何從SkyDrive下載和保存文件

[英]WP7 - How to download and save files from skydrive

我必須將文件從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方法中保存文件?

我找到解決方案:

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();
        }
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM