2013-06-10 5 views
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를 입력 한 다음 해당 위치로 파일을 업로드 하시겠습니까?

답변

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) 
{ 
} 
+0

감사합니다. 폴더가 이미 존재하면 그 폴더의 folderID를 어떻게 얻을 수 있습니까? – Danson

+0

JSON 응답을 구문 분석/역 직렬화하여 특정 폴더의 ID를 가져와야합니다. – Xyroid

+0

[Live SDK 도우미] (https://github.com/ScottIsAFool/LiveSDKHelper)를 확인하십시오 – Xyroid