Question

I am downloading a text file from skydrive using LiveConnectAPI for my windows phone 7 app
The Text file contains the XML data that i need to write in my IsolatedStorage

The Problem is when i download the file from the skydrive and write to the IsolatedStorage
I get NULL in the IsolatedStream.
I need to write the XML content of the TextFile that is in the skydrive root folder.

Note:- The File named userData.txt is in "me/skydrive/files"(Root Folder of skydrive,Please correct me if i am wrong in accessing root folder)


string id = string.Empty;
>client.GetCompleted += (obj, args) =>
                {
                   List<Object> items = args.Result["data"] as List<Object>;
                    foreach (object item in items)
                    {
                        Dictionary<string, object> file = item as Dictionary<string, object>;
                        if (file["name"].ToString() == "userData.txt")
                        {
                            id = file["id"].ToString();
                            break;
                        }
                    }

                    client.DownloadAsync(id+"/content");

                };

                client.GetAsync("me/skydrive/files");

When Download Completes

client.DownloadCompleted += (o, a) =>
             {
                MemoryStream outputStream = (MemoryStream)a.Result;

//Saving the file to Isolated Storage.

                var myStore = IsolatedStorageFile.GetUserStoreForApplication();
                IsolatedStorageFileStream myFileStream = myStore.CreateFile(GlobalConstants.cnst_storefile_name);
                myFileStream.Write(outputStream.GetBuffer(), 0, (int)outputStream.Length);


                myFileStream.Close();

                StreamReader reader = new StreamReader(new IsolatedStorageFileStream(GlobalConstants.cnst_storefile_name, FileMode.Open, myStore));
                string rawData = reader.ReadToEnd();
                reader.Close();

            };

        }
Was it helpful?

Solution

Can you check which version of the LiveConnect library you are using. Microsoft recently made some breaking changes to SkyDrive and code built with older versions of the library does not work any more. You want version 5.4 of the library.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top