void updateFileList(object path) { try { Path_Lab.Text = "当前路径:" + path.ToString().Replace("apps", "我的应用数据"); var jobj = JObject.Parse(WebTool.GetHtml($"https://pcs.baidu.com/rest/2.0/pcs/file?method=list&access_token={Program.config.Access_Token}&path=" + Uri.EscapeDataString($"{path.ToString()}"))); FilelistView.BeginUpdate(); FilelistView.Items.Clear(); Fileinfo.Clear(); foreach (JObject job in jobj["list"]) { DiskFileInfo fileinfo = JsonConvert.DeserializeObject <DiskFileInfo>(job.ToString()); FilelistView.Items.Add(fileinfo.getName()); this.Fileinfo.Add(fileinfo.getName(), fileinfo); if (fileinfo.isdir == 1) { setEndItemImageKey("Dir.png"); } else { setEndItemImageKey(getIconImage(fileinfo.getSuffix())); } } FilelistView.EndUpdate(); } catch (Exception ex) { MessageBox.Show("更新文件列表时遇到意外的错误: " + ex.ToString()); } Info_Lab.Text = "等待中..."; }
private void 文件信息ToolStripMenuItem_Click_1(object sender, EventArgs e) { if (FilelistView.SelectedIndices.Count <= 0) { MessageBox.Show("你没有选中任何文件哦"); return; } if (!Fileinfo.ContainsKey(FilelistView.SelectedItems[0].Text)) { MessageBox.Show("出现了未知错误! 请刷新重试"); return; } DiskFileInfo info = Fileinfo[FilelistView.SelectedItems[0].Text]; MessageBox.Show( "文件名: " + info.getName() + Environment.NewLine + "文件大小: " + (getSizeGB(info.size) < 1 ? getSizeMB(info.size) + " MB" : getSizeGB(info.size) + " GB") + Environment.NewLine + "文件路径: " + info.path.Replace("apps", "我的应用数据") + Environment.NewLine + "是不是文件夹: " + (info.isdir == 1?"是":"不是") , "文件信息" ); }