WP7-Skydrive API下载任何文件并保存隔离存储

时间:2012-07-30 19:53:04

标签: c# windows-phone-7 onedrive

我正在尝试在skydrive上下载文件,但它无法正常工作。

            LiveConnectClient client = new LiveConnectClient(session);
        client.DownloadCompleted += new EventHandler<LiveDownloadCompletedEventArgs>(DownloadCompleted);
        client.DownloadAsync(fileid);
        //-----------------------------------------------------------------
        void DownloadCompleted(object sender, LiveOperationCompletedEventArgs e)
        {
            StreamReader reader = new StreamReader(e.Result);
            string text = reader.ReadToEnd();
            IsolatedStorageFile Isofiles = IsolatedStorageFile.GetUserStoreForApplication();
            using (var isoFileStream = new IsolatedStorageFileStream("Testfile", FileMode.OpenOrCreate, Isofiles))
            {
                using (var isoFileWriter = new StreamWriter(isoFileStream))
                {
                    isoFileWriter.Write(text);
                }
            }
        }

我做错了什么?

1 个答案:

答案 0 :(得分:0)

您只能使用此行获取元数据

client.DownloadAsync(fileid);

像这样添加/ content到fileid以获取实际的文件内容。

client.DownloadAsync(fileid + "/content");