問題描述
WP7-Skydrive API 下載任何文件並保存隔離存儲 (WP7-Skydrive API Download Any file and Save Isolated Storage)
I'm trying to download file on skydrive, but it isn't working.
LiveConnectClient client = new LiveConnectClient(session);
client.DownloadCompleted += new EventHandler<LiveDownloadCompletedEventArgs>(DownloadCompleted);
client.DownloadAsync(fileid);
//-----------------------------------------------------------------
void DownloadCompleted(object sender, LiveOperationCompletedEventArgs e)
{
StreamReader reader = new StreamReader(e.Result);
string text = reader.ReadToEnd();
IsolatedStorageFile Isofiles = IsolatedStorageFile.GetUserStoreForApplication();
using (var isoFileStream = new IsolatedStorageFileStream("Testfile", FileMode.OpenOrCreate, Isofiles))
{
using (var isoFileWriter = new StreamWriter(isoFileStream))
{
isoFileWriter.Write(text);
}
}
}
What am I doing wrong?
參考解法
方法 1:
Your only getting the metadata with this line
client.DownloadAsync(fileid);
Add /content to the fileid like this to get the actual filecontent.
client.DownloadAsync(fileid + "/content");