Upload file to skydrive through SkyDrive API(通过 SkyDrive API 将文件上传到 skydrive)
问题描述
我尝试通过 Windows 8 应用程序中的 SkyDrive API 将文本文件上传到我的 skydrive 或至少在 SD 中创建新文本文件并编辑其内容.我该怎么做?
I try to upload a text file to my skydrive or at least create new text file in SD and edit it's content, through SkyDrive API in my Windows 8 application. How can I do that?
我试图做这样的事情:
LiveConnectClient client = new LiveConnectClient(session);
var fileData = new Dictionary<string, object>();
fileData.Add("name", "new_file.txt");
try
{
LiveOperationResult fileOperationResult = await client.PutAsync("me/skydrive", fileData);
this.infoTextBlock.Text = fileOperationResult.ToString();
}
catch (LiveConnectException exception)
{
this.infoTextBlock.Text = exception.Message;
}
但我得到错误提供的请求无效.无法更新根 SkyDrive 文件夹."如果我写像me/skydrive/"这样的东西,我会得到提供的 URL 无效.不支持请求的路径 ''".方法 LiveConnectClient.PutAsync 只允许我更新现有属性(但不是它的内容).
but I get error "The provided request is not valid. The root SkyDrive folder cannot be updated." If I write something like "me/skydrive/" I get "The provided URL is not valid. The requested path '' is not supported". Method LiveConnectClient.PutAsync allows me only to update existing properties (but not it's content).
应该怎么做才合适?
顺便说一句 - LCDC(http://msdn.microsoft.com/en-us/library/live/hh826531.aspx) 上的内容是否更新?我问是因为文档中的某些方法在 dll 中不存在(例如 LiveConnectClient.Upload.只有 BackgroundUploadAsync).
Btw - Is content on LCDC(http://msdn.microsoft.com/en-us/library/live/hh826531.aspx) updated? I'm asking because some methods, which are in documentation, doesn't exist in dlls (f.e. LiveConnectClient.Upload. There's only BackgroundUploadAsync).
提前感谢您的帮助,迈克尔
Thanks for help in advance, Micheal
推荐答案
关闭,但正如我所写:我不能使用 client.upload 方法,因为 LiveConnectClient 类不包含它.这就是我询问网站内容更新的原因.
Close but as I wrote: I can't use client.upload method because LiveConnectClient class doesn't contain it. That's why I asked about site content update.
无论如何 - 我有答案:
Anyway - I've got an answer:
//create a StorageFile (here is one way to do that if it is stored in your ApplicationData)
StorageFile file = awaitApplicationData.Current.LocalFolder.GetFileAsync("yourfilename.txt");
try {
client = new LiveConnectClient(session);
LiveOperationResult operationResult = await client.BackgroundUploadAsync("me/skydrive", file.Name, file, OverwriteOption.Overwrite);
}
catch (LiveConnectException exception) {
//handle exception
}
这篇关于通过 SkyDrive API 将文件上传到 skydrive的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:通过 SkyDrive API 将文件上传到 skydrive


- C# 中多线程网络服务器的模式 2022-01-01
- 如何用自己压缩一个 IEnumerable 2022-01-01
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01
- C#MongoDB使用Builders查找派生对象 2022-09-04
- MoreLinq maxBy vs LINQ max + where 2022-01-01
- 输入按键事件处理程序 2022-01-01
- WebMatrix WebSecurity PasswordSalt 2022-01-01
- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01