gpt4 book ai didi

c# - 如何从 OneDrive 下载文件

转载 作者:太空狗 更新时间:2023-10-29 22:10:40 24 4
gpt4 key购买 nike

我想从 One Drive 下载公用文件夹中的文件,但它不下载文件。这是场景:

在公用文件夹中,我有另一个文件夹,里面有多个文件,可以广泛访问。出于测试目的,我共享了公用文件夹中的所有文件(如果共享方式正确,我不会这样做)。

提供以下链接供我下载文件:

  1. 来自共享文件夹链接 https://onedrive.live.com/redir?resid=DBBC281099F4FE69!646&authkey=!AGRCGuw8Y2_p9mA&ithint=folder%2c.mp3
  2. 来自公共(public)文件夹链接 https://onedrive.live.com/redir?resid=DBBC281099F4FE69%21646
  3. 直接链接 http://1drv.ms/1z9XlW6 -

我正在使用 BackgroundTransferRequest 使用以下代码下载文件:

string filePathToDownload = string.Empty, fileName = "111.mp3";
filePathToDownload = "http://1drv.ms/1z9XlW6";

Uri transferUri = new Uri(Uri.EscapeUriString(filePathToDownload), UriKind.RelativeOrAbsolute);
BackgroundTransferRequest transferRequest = new BackgroundTransferRequest(transferUri);
transferRequest.Method = "GET";
transferRequest.TransferPreferences = TransferPreferences.AllowCellularAndBattery;

Uri downloadUri = new Uri(DataSource.TEMPDOWNLOADLOCATION + fileName, UriKind.RelativeOrAbsolute);
transferRequest.DownloadLocation = downloadUri;
transferRequest.Tag = fileName;

文件大小为 300Kb,但这只下载了 6Kb。

我怎样才能直接从上面的链接(其中任何一个)下载文件?

谢谢!

最佳答案

如果您将 url 中的 redir 替换为 download,您将获得原始文件而不是网页,即

https://onedrive.live.com/download?resid=DBBC281099F4FE69%21646

关于c# - 如何从 OneDrive 下载文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24553115/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com