Upload file to skydrive through SkyDrive API

后端 未结 3 1639
说谎
说谎 2020-12-17 06:17

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

3条回答
  •  旧巷少年郎
    2020-12-17 06:47

    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                
    }
    

提交回复
热议问题