Ionic.Zip.ZipFile.RemoveEntries C# (CSharp) Method

RemoveEntries() public method

This method removes a collection of entries from the ZipFile, by name.
public RemoveEntries ( System entriesToRemove ) : void
entriesToRemove System /// A collection of strings that refer to names of entries to be removed /// from the ZipFile. For example, you can pass in an array or a /// List of Strings that provide the names of entries to be removed. ///
return void
        public void RemoveEntries(System.Collections.Generic.ICollection<String> entriesToRemove)
        {
            if (entriesToRemove == null)
                throw new ArgumentNullException("entriesToRemove");

            foreach (String e in entriesToRemove)
            {
                this.RemoveEntry(e);
            }
        }

Same methods

ZipFile::RemoveEntries ( System entriesToRemove ) : void

Usage Example

Beispiel #1
1
        /// <summary>
        /// Installs mods from instMods into minecraft.jar
        /// </summary>
        private void InstallMods()
        {
            OnStart();
            //running = true;

            //ArrayList cFiles = new ArrayList();

            string mcBin = Target.BinDir;
            string mcJar = Path.Combine(mcBin, "minecraft.jar");
            string mcBackup = Path.Combine(mcBin, "mcbackup.jar");

            Status = "Installing mods - Backing up minecraft.jar...";
            if (!File.Exists(mcBackup))
            {
                File.Copy(mcJar, mcBackup);
            }

            TaskStep++; // STEP
            Status = "Installing mods - Adding class files...";
            try
            {
                File.Delete(mcJar);
            } catch (IOException e)
            {
                if (e.Message.Contains("being used"))
                {
                    OnErrorMessage("Can't install mods because minecraft.jar is being used " +
                        "by another process. If you have minecraft.jar open in 7-zip, WinRAR " +
                        "or any other program, please close it and then try again.");
                    Cancel();
                }
            }
            File.Copy(mcBackup, mcJar);
            ZipFile jarFile = new ZipFile(mcJar);

            if (!Directory.Exists(Target.InstModsDir))
                Directory.CreateDirectory(Target.InstModsDir);

            AddToJar(Target.InstModsDir, jarFile);

            TaskStep++; // STEP
            Status = "Installing mods - Removing META-INF...";
            string metaInfRegex = Path.Combine("META-INF", "*");
            if (jarFile.SelectEntries(metaInfRegex) != null)
            {
                Console.WriteLine("Removing META-INF");
                jarFile.RemoveEntries(jarFile.SelectEntries(metaInfRegex));
            }

            TaskStep++; // STEP
            Status = "Installing mods - Saving minecraft.jar...";
            jarFile.Save(mcJar);

            TaskStep++; // STEP
            Status = "Installing mods - Removing temporary files...";
            if (Directory.Exists(Path.Combine(Target.RootDir, MODTEMP_DIR_NAME)))
            {
                Directory.Delete(Path.Combine(Target.RootDir, MODTEMP_DIR_NAME), true);
            }

            TaskStep++; // STEP
            Status = "Installing mods - Done.";
            //running = false;
            OnComplete();
        }
All Usage Examples Of Ionic.Zip.ZipFile::RemoveEntries