Exemplo n.º 1
0
        public void InsertZipToDir(string newway)
        {
            try
            {
                FolderMethods.DeleteDirectory("ExtractData");
            }
            catch { }
            FolderMethods.CreateDirectory("ExtractData");

            int    ZipPlace   = path.IndexOf(".archive.zip\\");
            string ArchiveWay = path.Substring(ZipPlace + 13);
            string path1      = path.Substring(0, ZipPlace + 12);

            using (ZipFile zip = ZipFile.Read(path1))
            {
                if (path[path.Length - 1] == '/')
                {
                    ArchiveWay = ArchiveWay.Remove(ArchiveWay.Length - 1, 1) + "\\";
                    foreach (ZipEntry e in zip)
                    {
                        if (e.FileName.Contains(ArchiveWay.Replace('\\', '/')) && e.FileName.IndexOf(ArchiveWay.Replace('\\', '/')) == 0)
                        {
                            e.Extract("ExtractData", ExtractExistingFileAction.DoNotOverwrite);
                        }
                    }
                    FolderMethods.CopyDir("ExtractData\\" + ArchiveWay, newway + '\\' + ArchiveWay);

                    FolderMethods.DeleteDirectory("ExtractData");
                }
                else
                {
                    foreach (ZipEntry e in zip)
                    {
                        if (e.FileName == ArchiveWay.Replace('\\', '/'))
                        {
                            e.Extract("ExtractData", ExtractExistingFileAction.DoNotOverwrite);
                        }
                    }

                    FileMethods.copy("ExtractData\\" + ArchiveWay, newway, false);
                    FolderMethods.DeleteDirectory("ExtractData");
                }
            }
        }
Exemplo n.º 2
0
 private void MENU2(object sender, EventArgs e)
 {
     if (view.getsetFi.Contains(".zip"))
     {
         new ZippedFile(view.getsetFi).Delete(view.getsetListView.SelectedItems[0].Text);
     }
     else
     {
         if (view.getsetListView.SelectedItems[0].Tag.ToString() == "file")
         {
             FileMethods.delete(FileMethods.Combine(view.getsetFi, view.getsetListView.SelectedItems[0].Text));
         }
         else
         {
             FolderMethods.DeleteDirectory(FileMethods.Combine(view.getsetFi, view.getsetListView.SelectedItems[0].Text));
         }
     }
     view.renewList();
 }
Exemplo n.º 3
0
        public void InsertZipToZip(string newWay)
        {
            int    ZipPlace   = path.IndexOf(".archive.zip\\");
            string ArchiveWay = path.Substring(ZipPlace + 13);
            string path1      = path.Substring(0, ZipPlace + 12);

            try
            {
                FolderMethods.DeleteDirectory("ExtractData");
            }
            catch { }
            FolderMethods.CreateDirectory("ExtractData");
            int    newZipPlace   = newWay.IndexOf(".archive.zip");
            string newArchiveWay = newWay.Substring(newZipPlace);
            string newpath       = newWay.Substring(0, newZipPlace + 12);

            if (ArchiveWay[ArchiveWay.Length - 1] == '/')
            {
                ArchiveWay = ArchiveWay.Remove(ArchiveWay.Length - 1, 1) + "\\";
                if (newArchiveWay != "")
                {
                    newArchiveWay = newArchiveWay.Remove(newArchiveWay.Length - 1, 1) + "\\";
                }
                else
                {
                    newArchiveWay = "\\";
                }
                using (ZipFile zip = ZipFile.Read(path1))
                {
                    foreach (ZipEntry e in zip)
                    {
                        if (e.FileName.Contains(ArchiveWay.Replace('\\', '/')) && e.FileName.IndexOf(ArchiveWay.Replace('\\', '/')) == 0)
                        {
                            e.Extract("ExtractData", ExtractExistingFileAction.DoNotOverwrite);
                        }
                    }
                }
            }
            else
            {
                using (ZipFile zip = ZipFile.Read(path))
                {
                    foreach (ZipEntry e in zip)
                    {
                        if (e.FileName == ArchiveWay.Replace('\\', '/'))
                        {
                            e.Extract("ExtractData", ExtractExistingFileAction.DoNotOverwrite);
                        }
                    }
                }
            }

            while (newArchiveWay[newArchiveWay.Length - 1] != '\\')
            {
                newArchiveWay = newArchiveWay.Remove(newArchiveWay.Length - 1, 1);
            }
            using (ZipFile newzip = ZipFile.Read(newpath))
            {
                newzip.AddItem("ExtractData\\" + ArchiveWay, ArchiveWay.Replace('\\', '/'));
                newzip.Save();
            }
            FolderMethods.DeleteDirectory("ExtractData");
        }