2013-05-31 75 views

回答

1

什麼棘手位代碼..對於任何感興趣的人,您可以這樣做:

// This button reads the file from skydrive and puts it into isolated storage 
private async void Button_Click(object sender, RoutedEventArgs e) 
{ 
    string id = string.Empty; 
    LiveOperationResult result = await this.client.GetAsync("me/skydrive/files"); 

    List<object> items = result.Result["data"] as List<object>; 

    foreach (object item in items) 
    { 
     IDictionary<string, object> file = item as IDictionary<string, object>; 
     if (file["name"].ToString() == "somefile.txt") 
     { 
      id = file["id"].ToString(); 
     } 
    } 

    MessageBox.Show(id.ToString()); 

    LiveDownloadOperationResult result2 = await client.DownloadAsync(string.Format("{0}/content", id)); 
    Stream stream = result2.Stream; 
    using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication()) 
    { 
     using (IsolatedStorageFileStream fileToSave = storage.OpenFile("foo.txt", FileMode.Create, FileAccess.ReadWrite)) 
     { 
      stream.CopyTo(fileToSave); 
      stream.Flush(); 
      stream.Close(); 
     } 
    } 
}