Ejemplo n.º 1
0
        public void Error_UseOpenReaderWith_ZIS_wi10923()
        {
            string zipFileToCreate = "UseOpenReaderWith_ZIS.zip";

            CreateSmallZip(zipFileToCreate);

            // mixing OpenReader and ZipInputStream is a no-no!!
            int n;
            var buffer = new byte[2048];

            // Use OpenReader with ZipInputStream.
            // This must fail.
            TestContext.WriteLine("Reading with ZipInputStream");
            using (var zip = FileSystemZip.CreateInputStream(zipFileToCreate))
            {
                ZipEntry entry;
                while ((entry = zip.GetNextEntry()) != null)
                {
                    TestContext.WriteLine("  Entry: {0}", entry.FileName);
                    using (Stream file = entry.OpenReader())
                    {
                        while ((n = file.Read(buffer, 0, buffer.Length)) > 0)
                        {
                            ;
                        }
                    }
                    TestContext.WriteLine("  -- OpenReader() is done. ");
                }
            }
        }
Ejemplo n.º 2
0
        public void Error_UseZipEntryExtractWith_ZIS_wi10355()
        {
            string zipFileToCreate = "UseOpenReaderWith_ZIS.zip";

            CreateSmallZip(zipFileToCreate);

            // mixing ZipEntry.Extract and ZipInputStream is a no-no!!

            string extractDir = "extract";

            // Use ZipEntry.Extract with ZipInputStream.
            // This must fail.
            TestContext.WriteLine("Reading with ZipInputStream");
            using (var zip = FileSystemZip.CreateInputStream(zipFileToCreate))
            {
                ZipEntry entry;
                while ((entry = zip.GetNextEntry()) != null)
                {
                    entry.Extract(extractDir, Ionic.Zip.ExtractExistingFileAction.OverwriteSilently);
                }
            }
        }