简体   繁体   中英

How to download and upload file to SkyDrive via Live Connect SDK

I have an app that I want to download & upload a simple .txt file with a URL inside. I have downloaded Live Connect SDK V5.4, referenced the documentation, but it appears that the documentation is incorrect. The sample code uses event handlers for when a download/upload is complete, but that no longer can be used in V5.4.

I have two methods, downURL & upURL. I have started working on downURL:

    private async void downURL()
    {
        try
        {
            LiveDownloadOperationResult download = await client.DownloadAsync("URL.txt");
        }
        catch { }
    }

I am not sure what I am suppose to use for the path, I put "URL.txt" for now, I've seen some examples with "/me/". Do I need this? The file does not need to be visible to the user, as the user can't really do anything with it, but it is vital for the app to work.

My question is how do I use the LiveDownloadOperationResult download to save the file to Isolated Storage Settings, get the text contents, and put that in a string? Also, if you know how to upload the file back up, the upload event handler looks the same (but without the Result variable).

This code help you download content a file which you want. It get content have format OpenXML Here, "item.id" is Id of "URL.txt".

private async void downURL()
{
    try
    {                   
                        LiveDownloadOperationResult operationResult = await client.DownloadAsync(item.id + "/Content?type=notebook");

                        StreamReader reader = new StreamReader(operationResult.Stream);

                        string Content = await reader.ReadToEndAsync(); 
    }
    catch { }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM