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

UpdateEntry() public method

Updates the given entry in the ZipFile, using the given delegates to open and close the stream that provides the content for the ZipEntry.
Calling this method is equivalent to removing the ZipEntry for the given file name and directory path, if it exists, and then calling . See the documentation for that method for further explanation.
public UpdateEntry ( string entryName, OpenDelegate opener, CloseDelegate closer ) : ZipEntry
entryName string /// The name, including any path, to use within the archive for the entry. ///
opener OpenDelegate /// the delegate that will be invoked to open the stream ///
closer CloseDelegate /// the delegate that will be invoked to close the stream ///
return ZipEntry
        public ZipEntry UpdateEntry(string entryName, OpenDelegate opener, CloseDelegate closer)
        {
            RemoveEntryForUpdate(entryName);
            return AddEntry(entryName, opener, closer);
        }

Same methods

ZipFile::UpdateEntry ( string entryName, Stream stream ) : ZipEntry
ZipFile::UpdateEntry ( string entryName, WriteDelegate writer ) : ZipEntry
ZipFile::UpdateEntry ( string entryName, byte byteContent ) : ZipEntry
ZipFile::UpdateEntry ( string entryName, string content ) : ZipEntry
ZipFile::UpdateEntry ( string entryName, string content, System encoding ) : ZipEntry

Usage Example

Ejemplo n.º 1
1
        public static string CompileNewXAP(HashSet<string> fullsetOfDlls, string shared)
        {
            var tempPath = Path.Combine(shared, Guid.NewGuid() + ".xap");
            using (
                var stream = Assembly.GetExecutingAssembly()
                                     .GetManifestResourceStream("sl_runner.xap.sl-50-xap.xap"))
            using (var baseZip = ZipFile.Read(stream))
            {
                var set = new HashSet<string>();
                var item = baseZip["AppManifest.xaml"];
                var xml = XDocument.Parse(new StreamReader(item.OpenReader()).ReadToEnd());
                using (
                    var zip = new ZipFile()
                    {
                        CompressionLevel = CompressionLevel.Default,
                        CompressionMethod = CompressionMethod.Deflate
                    })
                {
                    zip.AddEntry("AppManifest.xaml", new byte[] { });
                    foreach (var entry in baseZip.Entries)
                    {
                        if (entry.FileName.Contains(".dll"))
                        {
                            using (var memstream = new MemoryStream())
                            {
                                entry.OpenReader().CopyTo(memstream);
                                memstream.Seek(0, SeekOrigin.Begin);
                                zip.AddEntry(entry.FileName, memstream.ToArray());
                                set.Add(Path.GetFileName(entry.FileName));
                            }
                        }
                    }
                    var desc = xml.DescendantNodes().OfType<XElement>();

                    var parts = desc.Single(it => it.Name.LocalName.Contains("Deployment.Parts"));

                    foreach (var dll in fullsetOfDlls)
                    {
                        if (set.Contains(Path.GetFileName(dll)))
                            continue;
                        set.Add(Path.GetFileName(dll));
                        zip.AddFile(dll, "");
                        parts.Add(new XElement(XName.Get("AssemblyPart", "http://schemas.microsoft.com/client/2007/deployment"),
                                               new XAttribute(
                                                   XName.Get("Name", "http://schemas.microsoft.com/winfx/2006/xaml"),
                                                   Path.GetFileNameWithoutExtension(dll)),
                                               new XAttribute("Source", Path.GetFileName(dll))));
                    }
                    using (var memstream = new MemoryStream())
                    {
                        xml.Save(memstream, SaveOptions.OmitDuplicateNamespaces);
                        zip.UpdateEntry("AppManifest.xaml", memstream.ToArray());
                    }
                    zip.Save(tempPath);
                }
            }
            return tempPath;
        }
All Usage Examples Of Ionic.Zip.ZipFile::UpdateEntry