Beispiel #1
0
        private void Deserbtn_Click(object sender, EventArgs e)
        {
            var            serializer = new Serializer();
            OpenFileDialog openDialog = new OpenFileDialog();

            openDialog.DefaultExt = ".json";
            openDialog.Filter     = "Text files (*.zip)|*zip| JSON files (*.json)|*json| XML files (*.xml)|*xml| DAT files (*.dat)|*dat|BIN files (*.bin)|*bin";
            openDialog.ShowDialog();
            string fileName1     = "";
            string fileName      = openDialog.FileName;
            string FileExtension = Path.GetExtension(fileName);

            if (FileExtension == ".zip")
            {
                Path.GetFileNameWithoutExtension(fileName1) = Path.GetFileNameWithoutExtension(fileName1) + "new";
                fileName1 = fileName1.Replace(".zip", "");
                ZipFile.ExtractToDirectory(fileName, fileName1);
            }
            else if (FileExtension == ".gzip")
            {
                GZarchiv gZarchiv = new GZarchiv();
                string   newfile  = fileName;
                newfile = newfile.Replace(Path.GetExtension(newfile), ".gzip");

                gZarchiv.Zip(fileName, newfile);
            }
            if (FileExtension == ".bzip2")
            {
                Bz2Arch bz2Arch = new Bz2Arch();
                string  newfile = fileName;
                newfile = newfile.Replace(Path.GetExtension(newfile), ".bzip2");
                bz2Arch.Zip(fileName, newfile);
            }
            array = serializer.Deserialize(ReadyInbox, ReadyEvent, ReadyProject, ReadySub, array, fileName1);

            for (int i = 0; i < array.listIn.Count; i++)
            {
                AddInfoInboxGrid(array.listIn[i].nameItem);
            }
            for (int i = 0; i < array.listEv.Count; i++)
            {
                AddInfoTodayGrid(array.listEv[i].nameItem, array.listEv[i].dateItem, array.listEv[i].timeItem);
            }
            for (int i = 0; i < array.listProj.Count; i++)
            {
                AddInfoProject(array.listProj[i].nameItem);
            }
            for (int i = 0; i < array.listSub.Count; i++)
            {
                for (int ind = 0; ind <= treeView1.Nodes.Count - 1; ind++)
                {
                    if (treeView1.Nodes[ind].Text == array.listSub[i].prname)
                    {
                        treeView1.Nodes[ind].Nodes.Add(array.listSub[i].prname);
                    }
                }
            }

            array = null;
        }
Beispiel #2
0
        private void serbtn_Click(object sender, EventArgs e)
        {
            var    serializer = new Serializer();
            string fileName   = serializer.Serialize(ReadyInbox, ReadyEvent, ReadyProject, ReadySub, null);

            if (archBox.Text == "ZIP")
            {
                string newfile = fileName;

                newfile = newfile + ".zip";

                using (Ionic.Zip.ZipFile zip = new Ionic.Zip.ZipFile())                 // Создаем объект для работы с архивом
                {
                    zip.CompressionLevel = Ionic.Zlib.CompressionLevel.BestCompression; // MAX степень сжатия
                    zip.AddFile(fileName);
                    zip.Save(newfile);                                                  // Создаем архив
                }
            }
            else if (archBox.Text == "GZip")
            {
                GZarchiv gZarchiv = new GZarchiv();
                string   newfile  = fileName;
                newfile = newfile.Replace(Path.GetExtension(newfile), ".gzip");

                gZarchiv.Zip(fileName, newfile);
            }
            if (archBox.Text == "BZip2")
            {
                Bz2Arch bz2Arch = new Bz2Arch();
                string  newfile = fileName;
                newfile = newfile.Replace(Path.GetExtension(newfile), ".bzip2");
                bz2Arch.Zip(fileName, newfile);
            }
        }