简体   繁体   English

如何使用C#Windows App读取OneDrive文件夹

[英]How to read a onedrive folder using c# windows app

I am trying to follow a sample on MSDN to read the properties of a folder on onedrive, but I am running into some errors. 我试图按照MSDN上的示例来读取onedrive上文件夹的属性,但是遇到了一些错误。

Here is the tutorial I am following: http://msdn.microsoft.com/en-us/library/live/hh826522.aspx#reading_albums 这是我正在关注的教程: http : //msdn.microsoft.com/zh-cn/library/live/hh826522.aspx#reading_albums

The error I get when I run the code says: 运行代码时出现的错误提示:

"Error 1 'testRun.MainPage' does not contain a definition for 'session' and no extension method 'session' accepting a first argument of type 'testRun.MainPage' could be found (are you missing a using directive or an assembly reference?) C:\\Users\\me\\Desktop\\project" “错误1'testRun.MainPage'不包含'session'的定义,找不到扩展方法'session'接受类型为'testRun.MainPage'的第一个参数(您是否缺少using指令或程序集引用? )C:\\ Users \\ me \\ Desktop \\ project“

I have still looked into the issue, and haven't found out what I need to include for the LiveConnectClient parameter. 我仍然调查了这个问题,还没有找到我需要为LiveConnectClient参数添加的内容。 It only gives that it needs "LiveConnectClient session", and I am not sure what to place in for that. 它仅表明它需要“ LiveConnectClient会话”,而我不确定该在其中放置什么。

My Code: 我的代码:

private async void Button_logIn_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                LiveConnectClient liveClient = new LiveConnectClient(this.session);
                LiveOperationResult operationResult =
                    await liveClient.GetAsync("path/to/folder");
                dynamic result = operationResult.Result;
                this.Textblock_status.Text = string.Join(" ", "Album name:", result.name, "ID:", result.id);
            }
            catch (LiveConnectException exception)
            {
                this.Textblock_status.Text = "Error getting album info: " + exception.Message;
            }
        }

You need to make sure you're defining the session member, and populating it with a valid session prior to using it with LiveConnectClient. 在与LiveConnectClient一起使用之前,需要确保定义会话成员,并使用有效的会话填充它。 Check out the following documentation for a more complete example: 查看以下文档以获取更完整的示例:

http://msdn.microsoft.com/en-US/library/dn631823.aspx http://msdn.microsoft.com/en-US/library/dn631823.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用C#从OneDrive中的共享文件夹下载文件? - How to download a file from shared folder in onedrive using c#? 如何使用c#从app的安装文件夹中读取文件? - How to read file from the installation folder of app using c#? 如何使用 c# 或 PowerShell 检查 OneDrive 文件夹中文件/文件夹的状态是否已同步? - How can I check status of files/folders in OneDrive folder whether it is synced or not using c# or PowerShell? 如何使用Windows Phone API在OneDrive上重命名文件夹? - How to rename a folder on OneDrive using Windows Phone API? 如何使用OneDrive SDK将OneDrive上的文件夹/文件上传到Windows 10 UWP - How to upload a folder/file on onedrive using the onedrive sdk for windows 10 UWP 如何在不使用C#刷新应用程序的情况下动态读取文件夹中的XML文件? - How can I dynamically read XML files in a folder without refreshing my app using C#? 在Windows窗体中使用C#连接到oneDrive - Connect to oneDrive with C# in windows form Read a non C# Apps textbox using windows API from a C# Windows forms App - Read a non C# Apps textbox using windows API from a C# Windows forms App How to read and overwrite the Shell in windows using C# Windows Forms - How to read and overwrite the Shell in windows using C# Windows Forms 如何在 c# 中使用 Microsoft Graph Api 上传到 OneDrive - How to upload to OneDrive using Microsoft Graph Api in c#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM