从OneDrive下载.wav文件

时间:2014-04-12 09:54:22

标签: c# windows-phone-8 onedrive

我需要下载所有" .wav"名为"记录的文件夹内的文件"在用户OneDrive上。我使用此代码但下载的文件为0 kb。我无法在此代码中找到错误。

LiveOperationResult operationResult = await client.GetAsync(folderId + "/files");

                var iEnum = operationResult.Result.Values.GetEnumerator();
                iEnum.MoveNext();
                var files = iEnum.Current as IEnumerable;

                foreach (dynamic v in files)
                {
                    var downloadOperationResult = await client.DownloadAsync(v.id as string);
                    using (Stream downloadStream = downloadOperationResult.Stream)
                    {
                        if (downloadStream != null)
                        {
                            using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication())
                            {
                                if (!storage.DirectoryExists("Recorded")) storage.CreateDirectory("Recorded");
                                using (
                                    IsolatedStorageFileStream fileToSave = storage.OpenFile("/Recorded/" + v.name as string,
                                        FileMode.Create, FileAccess.ReadWrite))
                                {
                                    downloadStream.CopyTo(fileToSave);
                                    downloadStream.Flush();
                                    downloadStream.Close();
                                }
                            }
                        }
                    }
                }

1 个答案:

答案 0 :(得分:0)

看起来你错过了" / content"在您的DownloadAsync调用中。

 var downloadOperationResult = await client.DownloadAsync(v.id+"/content" as string);