/// <summary>
        /// Commits the updates.
        /// </summary>
        /// <remarks>Documented by Dev03, 2009-07-20</remarks>
        public void CommitUpdates()
        {
            ZipFile zipFile = null;

            try
            {
                zipFile          = new ZipFile(file.FullName);
                zipFile.UseZip64 = UseZip64.Off;  // AAB-20090720: Zip64 caused some problem when modifing the archive (ErrorReportHandler.cs) - Zip64 is required to bypass the 4.2G limitation of the original Zip format (http://en.wikipedia.org/wiki/ZIP_(file_format))

                ZipEntry errorReport = zipFile.GetEntry(Resources.ERRORFILE_NAME);

                MemoryStream stream = new MemoryStream();
                using (Stream s = GetZipStream(errorReport, zipFile))
                {
                    XmlDocument doc = new XmlDocument();
                    using (StreamReader reader = new StreamReader(s, Encoding.Unicode))
                    {
                        doc.LoadXml(reader.ReadToEnd());
                    }
                    foreach (Dictionary <string, string> value in values)
                    {
                        XmlElement xE = doc.CreateElement(value["nodeName"]);
                        xE.InnerText = value["value"].Trim();
                        XmlNode parentNode = doc.SelectSingleNode(value["parentPath"]);
                        if (parentNode == null)
                        {
                            return;
                        }
                        parentNode.AppendChild(xE);
                    }
                    doc.Save(stream);
                }
                ZipData data = new ZipData(stream);
                zipFile.BeginUpdate();
                zipFile.Delete(errorReport);    //delete first!
                zipFile.CommitUpdate();
                zipFile.BeginUpdate();
                zipFile.Add(data, errorReport.Name);
                zipFile.CommitUpdate();
            }
            finally
            {
                if (zipFile != null)
                {
                    zipFile.Close();
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Commits the updates.
        /// </summary>
        /// <remarks>Documented by Dev03, 2009-07-20</remarks>
        public void CommitUpdates()
        {
            ZipFile zipFile = null;
            try
            {
                zipFile = new ZipFile(file.FullName);
                zipFile.UseZip64 = UseZip64.Off;  // AAB-20090720: Zip64 caused some problem when modifing the archive (ErrorReportHandler.cs) - Zip64 is required to bypass the 4.2G limitation of the original Zip format (http://en.wikipedia.org/wiki/ZIP_(file_format))

                ZipEntry errorReport = zipFile.GetEntry(Resources.ERRORFILE_NAME);

                MemoryStream stream = new MemoryStream();
                using (Stream s = GetZipStream(errorReport, zipFile))
                {
                    XmlDocument doc = new XmlDocument();
                    using (StreamReader reader = new StreamReader(s, Encoding.Unicode))
                    {
                        doc.LoadXml(reader.ReadToEnd());
                    }
                    foreach (Dictionary<string, string> value in values)
                    {
                        XmlElement xE = doc.CreateElement(value["nodeName"]);
                        xE.InnerText = value["value"].Trim();
                        XmlNode parentNode = doc.SelectSingleNode(value["parentPath"]);
                        if (parentNode == null)
                            return;
                        parentNode.AppendChild(xE);
                    }
                    doc.Save(stream);
                }
                ZipData data = new ZipData(stream);
                zipFile.BeginUpdate();
                zipFile.Delete(errorReport);    //delete first!
                zipFile.CommitUpdate();
                zipFile.BeginUpdate();
                zipFile.Add(data, errorReport.Name);
                zipFile.CommitUpdate();
            }
            finally
            {
                if (zipFile != null)
                    zipFile.Close();
            }
        }