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();
};
}