private void Main_Load(object sender, EventArgs e) { System.Net.ServicePointManager.DefaultConnectionLimit = 999999; if (!Directory.Exists(Program.config.TempPath)) { Directory.CreateDirectory(Program.config.TempPath); } LoadConfig(); if (Program.config.WebDownload) { new WebDownload().Listen(); } new Thread(Upgraded).Start(); if (Program.config.Access_Token == "null" || Program.config.Access_Token == string.Empty) { return; } try { SpaceInfo info = JsonConvert.DeserializeObject <SpaceInfo>(WebTool.GetHtml("https://pcs.baidu.com/rest/2.0/pcs/quota?method=info&access_token=" + Program.config.Access_Token)); // Used_Lab.Text = string.Format("网盘已使用: {0} / {1} (GB)", (float)info.used / 1024 / 1024 / 1024, (float)info.quota / 1024 / 1024 / 1024); Text = string.Format("已登录账户 [{0}],已使用容量 {1} / {2} (GB)", DiskAPI.GetName(Program.config.Access_Token), (float)info.used / 1024 / 1024 / 1024, (float)info.quota / 1024 / 1024 / 1024); } catch (Exception ex) { LogTool.WriteLogError(typeof(Main), "更新容量信息时出现错误", ex); MessageBox.Show("更新容量信息时出现错误,请尝试重新登录"); return; } DownloadListView.View = View.Details; new Thread(updateFileList).Start(HomePath + Path); }
private void button2_Click(object sender, EventArgs e) { if (Program.config.Access_Token == "null" || Program.config.Access_Token == string.Empty) { MessageBox.Show("你还未登录呢"); return; } if (Info_Lab.Text == "正在刷新") { return; } Info_Lab.Text = "正在刷新"; try { SpaceInfo info = JsonConvert.DeserializeObject <SpaceInfo>(WebTool.GetHtml("https://pcs.baidu.com/rest/2.0/pcs/quota?method=info&access_token=" + Program.config.Access_Token)); Used_Lab.Text = string.Format("网盘已使用: {0} / {1} (GB)", (float)info.used / 1024 / 1024 / 1024, (float)info.quota / 1024 / 1024 / 1024); Text = string.Format("已登录账户 [{0}],已使用容量 {1} / {2} (GB)", DiskAPI.GetName(Program.config.Access_Token), (float)info.used / 1024 / 1024 / 1024, (float)info.quota / 1024 / 1024 / 1024); } catch (Exception ex) { LogTool.WriteLogError(typeof(Main), "更新容量信息时出现错误", ex); MessageBox.Show("更新容量信息时出现错误,请尝试重新登录"); return; } new Thread(updateFileList).Start(HomePath + Path); }