예제 #1
0
 void AddDownloadButton()
 {
     if (checkBox1.Checked)
     {
         Program.config.DownloadPath = textBox1.Text;
         Program.config.save();
     }
     if (!Directory.Exists(textBox1.Text))
     {
         MessageBox.Show("下载文件夹不存在!");
         return;
     }
     if (info.isdir == 1)
     {
         foreach (DiskFileInfo dfi in info.getFileList())
         {
             string downloadPath = (textBox1.Text + dfi.path.Replace(dfi.getName(), string.Empty).Replace("/apps/wp2pcs", string.Empty).Replace("/", "\\"));
             downloadPath = downloadPath.Substring(0, downloadPath.Length - 1);
             if (!Directory.Exists(downloadPath))
             {
                 Directory.CreateDirectory(downloadPath);
             }
             main.AddDownloadFile(dfi, downloadPath, dfi.getName());
         }
         this.Close();
         return;
     }
     main.AddDownloadFile(info, textBox1.Text, info.getName());
     this.Close();
 }
        public DiskFileInfo[] getFileList()
        {
            if (isdir != 1)
            {
                return(null);
            }
            ArrayList FileList = new ArrayList();
            JObject   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)));

            foreach (JObject job in jobj["list"])
            {
                DiskFileInfo fileinfo = JsonConvert.DeserializeObject <BaiduPanDownload.Data.DiskFileInfo>(job.ToString());
                if (fileinfo.isdir == 1)
                {
                    foreach (DiskFileInfo info in fileinfo.getFileList())
                    {
                        FileList.Add(info);
                    }
                    continue;
                }
                FileList.Add(fileinfo);
            }
            return((DiskFileInfo[])FileList.ToArray(typeof(DiskFileInfo)));
        }