示例#1
0
        private void DownloadAll(bool decrypt, string tid, string pass)
        {
            FolderSelectDialog fbox = new FolderSelectDialog();

            if (fbox.ShowDialog() == DialogResult.OK)
            {
                string rootPath = $@"{fbox.SelectedPath}\{DataList.topic_id}\";

                //create folder if doesn't exist
                if (!Directory.Exists(rootPath))
                {
                    Directory.CreateDirectory(rootPath);
                }

                Thread t = new Thread(() =>
                {
                    Invoke(new Action(() => {
                        foreach (Control c in Controls)
                        {
                            c.Enabled = false;
                        }
                    }));

                    foreach (var dir in DataList.directories)
                    {
                        string dirPath = $@"{rootPath}\{dir.name}\";

                        //create folder if doesn't exist
                        if (!Directory.Exists(dirPath))
                        {
                            Directory.CreateDirectory(dirPath);
                        }

                        foreach (var file in dir.data_list)
                        {
                            string filePath = dirPath + file.filename;
                            byte[] data     = (decrypt)
                                ? BCAT.GetDecBcat(file.url, BCAT.Module.nnBcat, ulong.Parse(tid, NumberStyles.HexNumber), pass)
                                : BCAT.GetRawBcat(file.url, BCAT.Module.nnBcat);

                            File.WriteAllBytes(filePath, data);
                        }
                    }

                    Invoke(new Action(() => {
                        foreach (Control c in Controls)
                        {
                            c.Enabled = true;
                        }
                    }));

                    SystemSounds.Asterisk.Play();
                });
                t.IsBackground = true;
                t.Start();
            }
        }
示例#2
0
        private void DownloadFile(bool decrypt, TreeNode node, string tid, string pass)
        {
            var dir  = DataList.directories[node.Parent.Index];
            var file = dir.data_list[node.Index];

            saveFileDialog1.FileName = file.filename;
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                Thread t = new Thread(() =>
                {
                    Invoke(new Action(() => {
                        foreach (Control c in Controls)
                        {
                            c.Enabled = false;
                        }
                    }));

                    byte[] data = (decrypt)
                        ? BCAT.GetDecBcat(file.url, BCAT.Module.nnBcat, ulong.Parse(tid, NumberStyles.HexNumber), pass)
                        : BCAT.GetRawBcat(file.url, BCAT.Module.nnBcat);

                    File.WriteAllBytes(saveFileDialog1.FileName, data);

                    Invoke(new Action(() => {
                        foreach (Control c in Controls)
                        {
                            c.Enabled = true;
                        }
                    }));

                    SystemSounds.Asterisk.Play();
                });
                t.IsBackground = true;
                t.Start();
            }
        }