我正在使用LiveConnectAPI为我的windows phone 7应用程序
从skydrive下载文本文件文本文件包含我需要在我的独立存储中写入的 XML 数据
问题是当我从skydrive 下载文件并写入IsolatedStorage 时,我在IsolatedStream
中得到NULL。我需要编写位于skydrive根文件夹
中的TextFile的 XML 内容。注意:- 名为userData.txt的文件位于“me/skydrive/files”(skydrive 的根文件夹,如果我访问根文件夹有误,请纠正我)
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");
下载完成时
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();
};
}