0

ファイルをスカイドライブにアップロードするコードは

LiveAuthClient authClient = new LiveAuthClient();
LiveLoginResult authResult = await authClient.LoginAsync(new List<string>() { "wl.basic", "wl.skydrive", "wl.skydrive_update" });
if (authResult.Status == LiveConnectSessionStatus.Connected)
{
    LiveConnectClient meClient = new LiveConnectClient(authResult.Session);

    StorageFolder storageFolder = KnownFolders.DocumentsLibrary;
    StorageFile sampleFile = await storageFolder.CreateFileAsync("sample.txt");
    await Windows.Storage.FileIO.WriteTextAsync(sampleFile, "Sample Content");

    LiveOperationResult result = await meClient.BackgroundUploadAsync("me/skydrive/testFolder", sampleFile.Name, sampleFile, OverwriteOption.Overwrite);
}

フォルダを作成するコードは

LiveAuthClient authClient = new LiveAuthClient();
LiveLoginResult authResult = await authClient.LoginAsync(new List<string>() { "wl.basic", "wl.skydrive", "wl.skydrive_update" });
try
{
    var folderData = new Dictionary<string, object>();
    folderData.Add("name", "Test Folder");
    LiveConnectClient liveClient = new LiveConnectClient(authResult.Session);
    LiveOperationResult operationResult =
        await liveClient.PostAsync("me/skydrive", folderData);
    dynamic result = operationResult.Result;
}
catch (LiveConnectException exception)
{
}

作成したフォルダーからフォルダー ID を取得し、その場所にファイルをアップロードするにはどうすればよいですか?

4

1 に答える 1

1
LiveAuthClient authClient = new LiveAuthClient();
LiveLoginResult authResult = await authClient.LoginAsync(new List<string>() { "wl.basic", "wl.skydrive", "wl.skydrive_update" });
try
{
    var folderData = new Dictionary<string, object>();
    folderData.Add("name", "Test Folder");
    LiveConnectClient liveClient = new LiveConnectClient(authResult.Session);
    LiveOperationResult operationResult =
        await liveClient.PostAsync("me/skydrive", folderData);
    dynamic result = operationResult.Result;
    var folderId = result.id;

    /*result is dynamic object, you can get the folder id with id property 
    operationResult.RawResult will return JSON response with some data related to 
    that folder */
}
catch (LiveConnectException exception)
{
}
于 2013-06-10T14:04:50.230 に答える