private async Task <bool> DownloadFile(string fileID, string whereToSave) { bool fileDownloadResult = false; string skydriveFileId = fileID; try { LiveConnectClient client = new Microsoft.Live.LiveConnectClient(authClient.Session); //create a target file with the correct name and extension StorageFile downloadedFile = await storageFolder.CreateFileAsync(whereToSave, CreationCollisionOption.ReplaceExisting); //pass in the file id (path) and the StorageFile you created and it's filled with the downloaded files data await client.BackgroundDownloadAsync(skydriveFileId + "/content", downloadedFile); fileDownloadResult = true; } catch (Exception e) { Debug.WriteLine(e.Message.ToString()); fileDownloadResult = false; } return(fileDownloadResult); }
public static async Task<bool> DownloadFile(string skyDriveFileId, StorageFile destinationFile) { try { if (destinationFile != null) { if (session == null) { await Login(); } var liveClient = new LiveConnectClient(session); LiveDownloadOperationResult result = await liveClient.BackgroundDownloadAsync(skyDriveFileId, destinationFile); return true; } return false; } catch (LiveConnectException exception) { throw new Exception("Unable to download file " + skyDriveFileId, exception); } }
internal void Download() { if (SelectedPhoto == null) { return; } LiveConnectClient downloadClient = new LiveConnectClient(App.Session); downloadClient.BackgroundDownloadCompleted += new EventHandler<LiveOperationCompletedEventArgs>(downloadClient_BackgroundDownloadCompleted); string path = SelectedPhoto.ID + "/content"; Uri downloadLocation = new Uri("/shared/transfers/" + SelectedPhoto.Title, UriKind.RelativeOrAbsolute); string userState = SelectedPhoto.ID; // arbitrary string to uniquely identify the request. downloadClient.BackgroundDownloadAsync(path, downloadLocation, userState); }