LitDev.LDZip.RemoveFromArchive C# (CSharp) Method

RemoveFromArchive() private static method

private static RemoveFromArchive ( ZipFile zip, string fileToRemove ) : void
zip Ionic.Zip.ZipFile
fileToRemove string
return void
        private static void RemoveFromArchive(ZipFile zip, string fileToRemove)
        {
            try
            {
                if (zip.ContainsEntry(fileToRemove))
                {
                    zip.RemoveEntry(fileToRemove);
                }
                else
                {
                    List<string> toRemove = new List<string>();
                    foreach (ZipEntry e in zip)
                    {
                        if (e.FileName.StartsWith(fileToRemove + "/")) toRemove.Add(e.FileName);
                    }
                    foreach (string element in toRemove)
                    {
                        zip.RemoveEntry(element);
                    }
                }
            }
            catch (Exception ex)
            {
                Utilities.OnError(Utilities.GetCurrentMethod(), ex);
            }
        }