However, one thing that wasn't clear to me (from the docs) was how to iterate through the contents of a folder while, for example, searching for a particular file.
So...here's a bare-bones code snippet that shows how to search the root folder of the signed-in user's SkyDrive for the file "test.txt".
private void FindFileTestDotTxt() { client.GetCompleted += new EventHandler<LiveOperationCompletedEventArgs>(client_GetCompleted); client.GetAsync("me/skydrive/files"); } void client_GetCompleted(object sender, LiveOperationCompletedEventArgs e) { Dictionary<string, object> resultDict = (Dictionary<string, object>) e.Result; List<object> items = (List<object>)resultDict["data"]; foreach (object o in items) { Dictionary<string, object> item = (Dictionary<string, object>)o; if (item["name"].ToString() == "test.txt") { // found it Console.WriteLine("File URL: {0}", item["source"].ToString()); break; } } }
No comments:
Post a Comment