private void _Internal_AddEntry_WriteDelegate(string[] files,
                                                      EncryptionAlgorithm crypto,
                                                      bool seekable,
                                                      int cycle,
                                                      string format,
                                                      int ignored)
        {
            int bufferSize = 2048;
            byte[] buffer = new byte[bufferSize];
            int n;

            for (int k = 0; k < compLevels.Length; k++)
            {
                string zipFileToCreate = Path.Combine(TopLevelDir, String.Format(format, compLevels[k].ToString()));
                string password = TestUtilities.GenerateRandomPassword();

                using (var zip = new ZipFile())
                {
                    TestContext.WriteLine("=================================");
                    TestContext.WriteLine("Creating {0}...", Path.GetFileName(zipFileToCreate));
                    TestContext.WriteLine("Encryption({0})  Compression({1})  pw({2})",
                                          crypto.ToString(), compLevels[k].ToString(), password);

                    zip.Password = password;
                    zip.Encryption = crypto;
                    zip.CompressionLevel = compLevels[k];

                    foreach (var file in files)
                    {
                        zip.AddEntry(file, (name, output) =>
                            {
                                using (var input = File.OpenRead(name))
                                {
                                    while ((n = input.Read(buffer, 0, buffer.Length)) != 0)
                                    {
                                        output.Write(buffer, 0, n);
                                    }
                                }
                            });
                    }


                    if (!seekable)
                    {
                        // conditionally use a non-seekable output stream
                        using (var raw = File.Create(zipFileToCreate))
                        {
                            using (var ns = new Alienlab.Zip.Tests.NonSeekableOutputStream(raw))
                            {
                                zip.Save(ns);
                            }
                        }
                    }
                    else
                        zip.Save(zipFileToCreate);
                }

                BasicVerifyZip(Path.GetFileName(zipFileToCreate), password);

                Assert.AreEqual<int>(files.Length, TestUtilities.CountEntries(zipFileToCreate),
                                     "Trial ({0},{1}): The zip file created has the wrong number of entries.", cycle, k);
            }
        }
        private static ZipOutputStream GetZipOutputStream(bool seekable, int fileOutputOption, string zipFileToCreate)
        {
            if (fileOutputOption == 0)
            {
                Stream raw = File.Create(zipFileToCreate);
                // conditionally use a non-seekable output stream
                if (!seekable)
                    raw = new Alienlab.Zip.Tests.NonSeekableOutputStream(raw);

                return new ZipOutputStream(raw);
            }

            return new ZipOutputStream(zipFileToCreate);
        }
        private static void _DotNetZip_CreateZip(List<string> filesToZip,
                                                 EncryptionAlgorithm encryption,
                                                 string password,
                                                 string comment,
                                                 string zipFileToCreate,
                                                 bool nonSeekable)
        {
            // Want to test the library when saving to non-seekable output streams.  Like
            // stdout or ASPNET's Response.OutputStream.  This simulates it.
            if (nonSeekable)
            {
                using (var outStream = new Alienlab.Zip.Tests.NonSeekableOutputStream(File.Create(zipFileToCreate)))
                {
                    using (ZipFile zip1 = new ZipFile())
                    {
                        zip1.Encryption = encryption;
                        if (zip1.Encryption != EncryptionAlgorithm.None)
                            zip1.Password = password;

                        zip1.AddFiles(filesToZip, "");
                        zip1.Comment = comment;
                        zip1.Save(outStream);
                    }
                }
            }
            else
            {
                using (ZipFile zip1 = new ZipFile())
                {
                    zip1.Encryption = encryption;
                    if (zip1.Encryption != EncryptionAlgorithm.None)
                        zip1.Password = password;

                    zip1.AddFiles(filesToZip, "");
                    zip1.Comment = comment;
                    zip1.Save(zipFileToCreate);
                }
            }
        }