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
- 将数据集转换为列表 2022-01-01
- SonarQube C# 分析失败“不是指针的有效行偏移" 2022-01-01
- 在 VB6 或经典 ASP 中使用 .NET 2022-01-01
- C# 9 新特性——record的相关总结 2023-04-03
- 如果条件可以为空 2022-01-01
- 更新 Visual Studio 中的 DataSet 结构以匹配新的 SQL 数据库结构 2022-01-01
- Mono https webrequest 失败并显示“身份验证或解密失败" 2022-01-01
- 获取C#保存对话框的文件路径 2022-01-01
- 重新排序 WPF TabControl 中的选项卡 2022-01-01
