locked
Creating a Windows 8 SkyDrive Metro API -- Issue with LiveDownloadOperationResult RRS feed

  • Question

  • I am using SDK 5.2 - I followed the guide below for downloading files from SkyDrive, but some things have changed in 5.2 for LiveDownloadOperationResult it seems.

    guide: http://msdn.microsoft.com/en-us/library/live/hh826531.aspx#downloading_files

    here is the code I am using (assume that there is proper authentication/sign-in/access ect)

            public async Task<IStorageFile> DownloadFile(string FileId)
            {
                try
                {
                    LiveConnectClient client = new LiveConnectClient(Session);
                    LiveDownloadOperationResult result = await client.BackgroundDownloadAsync(FileId);
    
                    return result.File;
                }
                catch (Exception ex)
                {
                    throw new SkyDriveAPIException(ex.Message, ex);
                }
            }

    I am trying to return a IStorageFile from the result.File property, but no matter what I place in the FileId parameter it will not populate it.  IE: {id}/content or {id}/picture.  The file does download and I get the filestream back, but I cannot get the IStorageFile.

    Any ideas?

    Thanks,

    Steve

    Tuesday, June 19, 2012 10:02 PM

Answers

  •                Just for your information, But the code is for windows 8 since it's what I am working on this moment.

                   //
                    LiveDownloadOperationResult opResult1 = await client.BackgroundDownloadAsync(imageshotlogId + "/content");
                    Stream fileStream1 = opResult1.Stream.AsStreamForRead();
                    StreamReader streamReader1 = new StreamReader(fileStream1);
                    string logText = streamReader1.ReadToEnd();

                    //
      Windows.Storage.StorageFolder localFolder = Windows.Storage.ApplicationData.Current.LocalFolder;
                    StorageFolder appRootFolder = await localFolder.CreateFolderAsync(gmediabookApp, CreationCollisionOption.OpenIfExists);
                    StorageFolder categoryFolder = await appRootFolder.CreateFolderAsync(folderName, CreationCollisionOption.OpenIfExists);
              
                    StorageFile imageshotlogStorageFile = await categoryFolder.CreateFileAsync(imageshotlog, CreationCollisionOption.OpenIfExists);
                    await FileIO.AppendTextAsync(imageshotlogStorageFile, logText);

    Wednesday, June 20, 2012 3:48 PM

All replies

  • No one can help me with downloading a file??
    Wednesday, June 20, 2012 2:50 PM
  •                Just for your information, But the code is for windows 8 since it's what I am working on this moment.

                   //
                    LiveDownloadOperationResult opResult1 = await client.BackgroundDownloadAsync(imageshotlogId + "/content");
                    Stream fileStream1 = opResult1.Stream.AsStreamForRead();
                    StreamReader streamReader1 = new StreamReader(fileStream1);
                    string logText = streamReader1.ReadToEnd();

                    //
      Windows.Storage.StorageFolder localFolder = Windows.Storage.ApplicationData.Current.LocalFolder;
                    StorageFolder appRootFolder = await localFolder.CreateFolderAsync(gmediabookApp, CreationCollisionOption.OpenIfExists);
                    StorageFolder categoryFolder = await appRootFolder.CreateFolderAsync(folderName, CreationCollisionOption.OpenIfExists);
              
                    StorageFile imageshotlogStorageFile = await categoryFolder.CreateFileAsync(imageshotlog, CreationCollisionOption.OpenIfExists);
                    await FileIO.AppendTextAsync(imageshotlogStorageFile, logText);

    Wednesday, June 20, 2012 3:48 PM
  • You can also do this...

    private async Task DownloadFile()
            {
                string skydriveFileId = "file.ea70cpp9e06ae7f3.EA50BB9EEF3!170";
    
                try
                {
                    //create a target file with the correct name and extension
                    StorageFile downloadedFile = await ApplicationData.Current.LocalFolder.CreateFileAsync("FileFromSkyDrive.txt");
    
                    //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);
                }
                catch (Exception e)
                {
                    infoTextBlock.Text = "Error downloading file: " + exception.Message;
                }
            }
    This is also Windows 8 code.


    • Edited by RBL_3 Wednesday, July 11, 2012 7:20 PM
    Wednesday, July 11, 2012 4:59 PM