我正在創建一個 UWP 應用程序,我想使用 Onedrive API,以便用戶可以在其 Onedrive 帳戶中保存文件的副本,但我不明白,到目前為止我只成功登錄了我想要的內容:上傳文件下載文件如果其中任何一個被修改,則進行同步創建文件夾刪除文件此代碼實現了登錄,但我無法超越此,就像繼續上傳文件或下載文件一樣 private async void btn_Login_Click(object sender, RoutedEventArgs e) { if (this.oneDriveClient == null) { try { // Setting up the client here, passing in our Client Id, Return Url, // Scopes that we want permission to, and building a Web Broker to // go do our authentication. this.oneDriveClient = await OneDriveClient.GetAuthenticatedMicrosoftAccountClient( clientId, returnUrl, scopes, webAuthenticationUi: new WebAuthenticationBrokerWebAuthenticationUi()); // Show in text box that we are connected. txtBox_Response.Text = "We are now connected"; // We are either just autheticated and connected or we already connected, // either way we need the drive button now. btn_GetDriveId.Visibility = Visibility.Visible; }我在 github 中創建了一個示例存儲庫:Onedrive Sync Files Sample我已經嘗試過使用 Dropbox、Gdrive,但它在 UWP 上的實現似乎要復雜得多,所以我選擇了 OneDrive。任何答案都會非常有幫助,提前致謝
1 回答

牧羊人nacy
TA貢獻1862條經驗 獲得超7個贊
如何在 C# 中使用 OneDrive API 同步文件
對于使用 OneDrive,我們建議您使用Windows 社區工具包中的OneDrive服務來實現 OneDrive功能。
入門
要使用 OneDrive API,您需要擁有一個訪問令牌,用于對您的應用程序進行身份驗證,以獲得用戶的一組特定權限。在本節中,您將學習如何:
注冊您的應用程序以獲取客戶端 ID 和客戶端密鑰。
使用令牌流或代碼流將用戶登錄到具有指定范圍的 OneDrive。
將用戶注銷(可選)。
- 1 回答
- 0 關注
- 203 瀏覽
添加回答
舉報
0/150
提交
取消