示例#1
0
        /// <summary>
        /// Сжать файл.
        /// </summary>
        /// <param name="sourceFilename">Имя исходного файла.</param>
        /// <param name="archiveFilename">Имя файла архива.</param>
        /// <returns>В случае успеха функция возвращает 0, при ошибке  1.</returns>
        private static int ExecuteCompress(string sourceFilename, string archiveFilename)
        {
            if (!File.Exists(sourceFilename))
            {
                Console.WriteLine("File not found:" + sourceFilename);
                return(1);
            }

            int errorType;

            using (GzipCompressor compressor = new GzipCompressor())
            {
                errorType = compressor.PackFile(new ArchiveSettings(sourceFilename, archiveFilename));
            }
            return(errorType);
        }
示例#2
0
        public void OneThreadCompressorTest()
        {
            string sourceFilename  = TestFolder.File("Emgu.chm");
            string archiveFilename = "!pack.Emgu.1_thread.gz";
            int    errorType;

            using (GzipCompressor compressor = new GzipCompressor())
            {
                errorType = compressor.PackFile(new ArchiveSettings(sourceFilename, archiveFilename)
                {
                    ThreadCount = 1
                });
            }
            Assert.AreEqual(errorType, 0);
            FileInfo fileInfo = new FileInfo(archiveFilename);

            Assert.AreEqual(fileInfo.Length, 11810196);
        }