从Onedrive下载.wav文件
-
21-12-2019 - |
题
我需要在用户OneDrive上下载名为“录制”的文件夹中的所有“.wav”文件。我正在使用这个代码,但下载的文件是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();
}
}
}
}
}
. 解决方案
看起来您在下载呼叫中缺少“/内容”。
var downloadOperationResult = await client.DownloadAsync(v.id+"/content" as string);
. 不隶属于 StackOverflow