ICSharpCode.SharpZipLib.Zip.ZipFile.BeginUpdate C# (CSharp) Method

BeginUpdate() public method

Begin updating this ZipFile archive.
public BeginUpdate ( ) : void
return void
        public void BeginUpdate() {
            if (Name==null) {
                BeginUpdate(new MemoryArchiveStorage(), new DynamicDiskDataSource());
            } else {
                BeginUpdate(new DiskArchiveStorage(this), new DynamicDiskDataSource());
            }
        }

Same methods

ZipFile::BeginUpdate ( IArchiveStorage archiveStorage ) : void
ZipFile::BeginUpdate ( IArchiveStorage archiveStorage, IDynamicDataSource dataSource ) : void

Usage Example

Example #1
2
        void TryDeleting(byte[] master, int totalEntries, int additions, params int[] toDelete)
        {
            MemoryStream ms = new MemoryStream();
            ms.Write(master, 0, master.Length);

            using (ZipFile f = new ZipFile(ms)) {
                f.IsStreamOwner = false;
                Assert.AreEqual(totalEntries, f.Count);
                Assert.IsTrue(f.TestArchive(true));
                f.BeginUpdate(new MemoryArchiveStorage());

                for (int i = 0; i < additions; ++i) {
                    f.Add(new StringMemoryDataSource("Another great file"),
                        string.Format("Add{0}.dat", i + 1));
                }

                foreach (int i in toDelete) {
                    f.Delete(f[i]);
                }
                f.CommitUpdate();

                /* write stream to file to assist debugging.
                                byte[] data = ms.ToArray();
                                using ( FileStream fs = File.Open(@"c:\aha.zip", FileMode.Create, FileAccess.ReadWrite, FileShare.Read) ) {
                                    fs.Write(data, 0, data.Length);
                                }
                */
                int newTotal = totalEntries + additions - toDelete.Length;
                Assert.AreEqual(newTotal, f.Count,
                    string.Format("Expected {0} entries after update found {1}", newTotal, f.Count));
                Assert.IsTrue(f.TestArchive(true), "Archive test should pass");
            }
        }
All Usage Examples Of ICSharpCode.SharpZipLib.Zip.ZipFile::BeginUpdate