Beispiel #1
0
        private void ts_open_Click(object sender, EventArgs e)
        {
            OpenFileDialog diag = new OpenFileDialog();

            diag.InitialDirectory = path;
            diag.Title            = "Open XBB Files ...";
            diag.Filter           = "XBB files (*.xbb, *.bin) | *.xbb; *.bin|All Files|*.*";

            if (diag.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            path    = Path.GetFullPath(diag.FileName);
            xbbFile = null;
            GC.Collect();

            FileStream   _FileTemp   = new FileStream(diag.FileName, FileMode.Open);
            BinaryReader _binaryread = new BinaryReader(_FileTemp);

            xbbFile = new xbb();
            xbbFile.Load(_binaryread.ReadBytes((int)_FileTemp.Length));
            _binaryread.Close();
            _FileTemp.Close();

            tlb_files.Text = xbbFile.getCount() + " files";

            cb_xbb.Items.Clear();

            for (int i = 0; i < xbbFile.getCount(); i++)
            {
                cb_xbb.Items.Add(xbbFile.getFileName(i));
            }

            cb_xbb.SelectedIndex = 0;

            ts_saveas.Enabled     = true;
            ts_unpack.Enabled     = true;
            uxTabControl1.Enabled = true;
        }
Beispiel #2
0
        private void ts_unpack_Click(object sender, EventArgs e)
        {
            Ookii.Dialogs.VistaFolderBrowserDialog folderdialog = new Ookii.Dialogs.VistaFolderBrowserDialog();

            folderdialog.SelectedPath = Program.AConfig.FilePath[0];

            progressBar1.Value   = 0;
            progressBar1.Maximum = (int)xbbFile.getCount();

            if (folderdialog.ShowDialog() == DialogResult.OK)
            {
                string pathe = folderdialog.SelectedPath + @"\" + Path.GetFileName(path).Replace(Path.GetExtension(path), "") + @"\";

                if (!Directory.Exists(pathe))
                {
                    Directory.CreateDirectory(pathe);
                }

                Thread nTh = new Thread(
                    new ThreadStart(() =>
                {
                    for (int i = 0; i < xbbFile.getCount(); i++)
                    {
                        File.WriteAllBytes(pathe + xbbFile.getFileName(i).Replace("\0", "") + "", xbbFile.getSelectedfile(i));

                        progressBar1.BeginInvoke(new Action(() =>
                        {
                            progressBar1.Value += 1;
                        }));
                    }

                    GC.Collect(9, GCCollectionMode.Forced);
                }));

                nTh.Start();

                File.WriteAllText(pathe + @"\" + "uniqueIDList" + ".json", JsonConvert.SerializeObject(xbbFile.getselectedUniq(), Formatting.Indented), Encoding.UTF8);
            }
        }