public async void recursiveExplorer(TreeNode currentNode, drive currentDrive) { try { driveList localList; localList = await getFileInfo(currentDrive); if (localList.data.Count() > 0) { foreach (drive i in localList.data) { if (i.id.StartsWith("folder")) { // MessageBox.Show(i.id); TreeNode node = currentNode.Nodes.Add(i.id, i.name); this.recursiveExplorer(node, i); node.ImageIndex = node.SelectedImageIndex = 0; } else if (i.id.StartsWith("file")) { // TreeNode nodes = treeView1.Nodes[currentNode.Index].Nodes.Add(i.name); TreeNode nodes = currentNode.Nodes.Add(i.id, i.name); nodes.ImageIndex = nodes.SelectedImageIndex = 1; } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public async Task <driveList> getFileInfo(drive thisDrive) { driveList resultList = null; try { LiveOperationResult result = await this.liveConnectClient.GetAsync(string.Concat(thisDrive.id, "/files")); JavaScriptSerializer ser = new JavaScriptSerializer(); resultList = ser.Deserialize <driveList>(result.RawResult); return(resultList); } catch (Exception ex) { MessageBox.Show(ex.Message); return(resultList); } }
public async void updateTree() { try { LiveOperationResult res = await this.liveConnectClient.GetAsync("me/skydrive/files"); JavaScriptSerializer ser = new JavaScriptSerializer(); driveList rootDriveList = ser.Deserialize <driveList>(res.RawResult); drive Rootdrive = new drive(); Rootdrive.name = "root"; Rootdrive.id = "me/skydrive"; treeView1.TopNode = new TreeNode(); recursiveExplorer(this.treeView1.TopNode, Rootdrive); } catch (Exception ex) { MessageBox.Show(ex.Message); } }