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

TestArchive() public method

Test an archive for integrity/validity
Testing will terminate on the first error found.
public TestArchive ( bool testData ) : bool
testData bool Perform low level data Crc check
return bool
        public bool TestArchive(bool testData) {
            return TestArchive(testData, TestStrategy.FindFirstError, null);
        }

Same methods

ZipFile::TestArchive ( bool testData, TestStrategy strategy, ZipTestResultHandler resultHandler ) : bool

Usage Example

Ejemplo n.º 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::TestArchive