当前位置: 首页>>代码示例>>C#>>正文


C# CompressionMethod类代码示例

本文整理汇总了C#中CompressionMethod的典型用法代码示例。如果您正苦于以下问题:C# CompressionMethod类的具体用法?C# CompressionMethod怎么用?C# CompressionMethod使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CompressionMethod类属于命名空间,在下文中一共展示了CompressionMethod类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ZipEntry

 public ZipEntry(ZipEntry entry)
 {
     _externalFileAttributes = -1;
     _method = CompressionMethod.Deflated;
     ZipFileIndex = -1L;
     if (entry == null)
     {
         throw new ArgumentNullException(nameof(entry));
     }
     _known = entry._known;
     Name = entry.Name;
     _size = entry._size;
     _compressedSize = entry._compressedSize;
     _crc = entry._crc;
     _dosTime = entry._dosTime;
     _method = entry._method;
     _comment = entry._comment;
     _versionToExtract = entry._versionToExtract;
     _versionMadeBy = entry._versionMadeBy;
     _externalFileAttributes = entry._externalFileAttributes;
     Flags = entry.Flags;
     ZipFileIndex = entry.ZipFileIndex;
     Offset = entry.Offset;
     _forceZip64 = entry._forceZip64;
     if (entry._extra != null)
     {
         _extra = new byte[entry._extra.Length];
         Array.Copy(entry._extra, 0, _extra, 0, entry._extra.Length);
     }
 }
开发者ID:ouyh18,项目名称:LtePlatform,代码行数:30,代码来源:ZipEntry.cs

示例2: Compress

 public void Compress(string sourceFilename, string targetFilename, FileMode fileMode, OutArchiveFormat archiveFormat,
     CompressionMethod compressionMethod, CompressionLevel compressionLevel, ZipEncryptionMethod zipEncryptionMethod,
     string password, int bufferSize, int preallocationPercent, bool check, Dictionary<string, string> customParameters)
 {
     bufferSize *= this._sectorSize;
     SevenZipCompressor compressor = new SevenZipCompressor();
     compressor.FastCompression = true;
     compressor.ArchiveFormat = archiveFormat;
     compressor.CompressionMethod = compressionMethod;
     compressor.CompressionLevel = compressionLevel;
     compressor.DefaultItemName = Path.GetFileName(sourceFilename);
     compressor.DirectoryStructure = false;
     compressor.ZipEncryptionMethod = zipEncryptionMethod;
     foreach (var pair in customParameters)
     {
         compressor.CustomParameters[pair.Key] = pair.Value;
     }
     using (FileStream sourceFileStream = new FileStream(sourceFilename,
         FileMode.Open, FileAccess.Read, FileShare.None, bufferSize,
         Win32.FileFlagNoBuffering | FileOptions.SequentialScan))
     {
         using (FileStream targetFileStream = new FileStream(targetFilename,
                fileMode, FileAccess.ReadWrite, FileShare.ReadWrite, 8,
                FileOptions.WriteThrough | Win32.FileFlagNoBuffering))
         {
             this.Compress(compressor, sourceFileStream, targetFileStream,
                 password, preallocationPercent, check, bufferSize);
         }
     }
 }
开发者ID:simony,项目名称:WinUtils,代码行数:30,代码来源:LocalArch.cs

示例3: RuntimeInfo

		public RuntimeInfo(CompressionMethod method, int compressionLevel, 
            int size, string password, bool getCrc)
		{
			this.method = method;
			this.compressionLevel = compressionLevel;
			this.password = password;
			this.size = size;
			this.random = false;

			original = new byte[Size];
			if (random) {
				System.Random rnd = new Random();
				rnd.NextBytes(original);
			}
			else {
				for (int i = 0; i < size; ++i) {
					original[i] = (byte)'A';
				}
			}

			if (getCrc) {
				Crc32 crc32 = new Crc32();
				crc32.Update(original, 0, size);
				crc = crc32.Value;
			}
		}
开发者ID:XiBeichuan,项目名称:hydronumerics,代码行数:26,代码来源:ZipTests.cs

示例4: CsvFile

        public CsvFile(Stream stream, DataFileMode fileMode, CompressionMethod compression, Encoding encoding, CultureInfo culture)
            : base(stream, fileMode, compression, encoding, culture)
        {
            InitializeMembers();

            Open();
        }
开发者ID:horvatferi,项目名称:graywulf,代码行数:7,代码来源:CsvFile.cs

示例5: ZipEntry

 public ZipEntry(ZipEntry entry)
 {
     externalFileAttributes = -1;
     method = CompressionMethod.Deflated;
     zipFileIndex = -1L;
     if (entry == null)
     {
         throw new ArgumentNullException("entry");
     }
     known = entry.known;
     name = entry.name;
     size = entry.size;
     compressedSize = entry.compressedSize;
     crc = entry.crc;
     dosTime = entry.dosTime;
     method = entry.method;
     comment = entry.comment;
     versionToExtract = entry.versionToExtract;
     versionMadeBy = entry.versionMadeBy;
     externalFileAttributes = entry.externalFileAttributes;
     flags = entry.flags;
     zipFileIndex = entry.zipFileIndex;
     offset = entry.offset;
     forceZip64_ = entry.forceZip64_;
     if (entry.extra != null)
     {
         extra = new byte[entry.extra.Length];
         Array.Copy(entry.extra, 0, extra, 0, entry.extra.Length);
     }
 }
开发者ID:ouyh18,项目名称:LteTools,代码行数:30,代码来源:ZipEntry.cs

示例6: FormattedDataFile

        protected FormattedDataFile(Stream stream, DataFileMode fileMode, CompressionMethod compression, Encoding encoding, CultureInfo culture)
            : base(stream, fileMode, compression)
        {
            InitializeMembers();

            this.encoding = encoding;
            this.culture = culture;
        }
开发者ID:horvatferi,项目名称:graywulf,代码行数:8,代码来源:FormattedDataFile.cs

示例7: ServerHello

 public ServerHello(ProtocolVersion ver, byte[] random, byte[] sessionID, CipherSuite suite, CompressionMethod compression, Extension[] extensions)
     : base(HandshakeType.ServerHello)
 {
     _version = ver;
     _random = random;
     _sessionID = sessionID;
     _cipherSuite = suite;
     _compression = compression;
     _extensions = extensions;
 }
开发者ID:kazuki,项目名称:opencrypto-tls,代码行数:10,代码来源:ServerHello.cs

示例8: SupportsMethod

 /// <summary>
 ///   Is the given compression method/algrithm supported?
 /// </summary>
 /// <param name="method"> </param>
 /// <returns> </returns>
 public bool SupportsMethod(CompressionMethod method)
 {
     ElementList nList = SelectElements(typeof (Method));
     foreach (Method m in nList)
     {
         if (m.CompressionMethod == method)
             return true;
     }
     return false;
 }
开发者ID:ridhouan,项目名称:teamlab.v6.5,代码行数:15,代码来源:Compression.cs

示例9: Ihdr

        public Ihdr(UInt32 width, UInt32 height, BitDepth bitDepth, ColorType colorType, CompressionMethod compressionMethod = CompressionMethod.Default, FilterMethod filterMethod = FilterMethod.Default, InterlaceMethod interlaceMethod = InterlaceMethod.None)
            : base(ChunkType.IHDR)
        {
            #region Sanity
            if(width == 0 || width > Int32.MaxValue)
                throw new ArgumentOutOfRangeException("width", "width must be greater than 0 and smaller than In32.MaxValue(2^31-1)");
            if(height == 0 || height > Int32.MaxValue)
                throw new ArgumentOutOfRangeException("height", "height must be greater than 0 and smaller than In32.MaxValue(2^31-1)");

            BitDepth[] allowedBitDepths;
            switch (colorType)
                {
                case ColorType.Grayscale:
                    if(!(allowedBitDepths = new[] { BitDepth._1, BitDepth._2, BitDepth._4, BitDepth._8, BitDepth._16 }).Contains(bitDepth))
                        throw new ArgumentOutOfRangeException("bitDepth", String.Format("bitDepth must be one of {0} for colorType {1}", allowedBitDepths.Aggregate("", (s, bd) => s + bd + ", ", s => s.Trim().Substring(0, s.Length - 2)), colorType));
                    break;
                case ColorType.Rgb:
                    if(!(allowedBitDepths = new[]{BitDepth._8, BitDepth._16}).Contains(bitDepth))
                        throw new ArgumentOutOfRangeException("bitDepth", String.Format("bitDepth must be one of {0} for colorType {1}", allowedBitDepths.Aggregate("", (s, bd) => s + bd + ", ", s => s.Trim().Substring(0, s.Length - 2)), colorType));
                    break;
                case ColorType.Palette:
                    if(!(allowedBitDepths = new[] { BitDepth._1, BitDepth._2, BitDepth._4, BitDepth._8}).Contains(bitDepth))
                        throw new ArgumentOutOfRangeException("bitDepth", String.Format("bitDepth must be one of {0} for colorType {1}", allowedBitDepths.Aggregate("", (s, bd) => s + bd + ", ", s => s.Trim().Substring(0, s.Length - 2)), colorType));
                    break;
                case ColorType.GrayscaleWithAlpha:
                    if(!(allowedBitDepths = new[] { BitDepth._8, BitDepth._16}).Contains(bitDepth))
                        throw new ArgumentOutOfRangeException("bitDepth", String.Format("bitDepth must be one of {0} for colorType {1}", allowedBitDepths.Aggregate("", (s, bd) => s + bd + ", ", s => s.Trim().Substring(0, s.Length - 2)), colorType));
                    break;
                case ColorType.Rgba:
                    if(!(allowedBitDepths = new[] { BitDepth._8, BitDepth._16}).Contains(bitDepth))
                        throw new ArgumentOutOfRangeException("bitDepth", String.Format("bitDepth must be one of {0} for colorType {1}", allowedBitDepths.Aggregate("", (s, bd) => s + bd + ", ", s => s.Trim().Substring(0, s.Length - 2)), colorType));
                    break;
                default:
                    throw new ArgumentOutOfRangeException("colorType", String.Format("Unknown colorType: {0}", colorType));
                }

            if(compressionMethod != CompressionMethod.Default)
                throw new ArgumentOutOfRangeException("compressionMethod", String.Format("Unknown compressionMethod: {0}", compressionMethod));
            if(filterMethod != FilterMethod.Default)
                throw new ArgumentOutOfRangeException("filterMethod", String.Format("Unknown filterMethod: {0}", filterMethod));

            var allowedInterlaceMethods = new[] {InterlaceMethod.None, InterlaceMethod.Adam7};
            if(!allowedInterlaceMethods.Contains(interlaceMethod))
                throw new ArgumentOutOfRangeException("interlaceMethod", String.Format("interlaceMethod must be one of {0}", allowedInterlaceMethods.Aggregate("", (s, bd) => s + bd + ", ", s => s.Trim().Substring(0, s.Length - 2))));

            #endregion

            Width = width;
            Height = height;
            BitDepth = bitDepth;
            ColorType = colorType;
            CompressionMethod = compressionMethod;
            FilterMethod = filterMethod;
            InterlaceMethod = interlaceMethod;
        }
开发者ID:Darcara,项目名称:LibApng,代码行数:55,代码来源:Ihdr.cs

示例10: ZipOutputStream

 public ZipOutputStream(Stream baseOutputStream, int bufferSize) : base(baseOutputStream, new Deflater(-1, true), bufferSize)
 {
     this.entries = new ArrayList();
     this.crc = new Crc32();
     this.defaultCompressionLevel = -1;
     this.curMethod = CompressionMethod.Deflated;
     this.zipComment = new byte[0];
     this.crcPatchPos = -1L;
     this.sizePatchPos = -1L;
     this.useZip64_ = ICSharpCode.SharpZipLib.Zip.UseZip64.Dynamic;
 }
开发者ID:huaminglee,项目名称:myyyyshop,代码行数:11,代码来源:ZipOutputStream.cs

示例11: ClientHelloMessage

        public ClientHelloMessage(TlsVersion version, byte[] randomBytes, byte[] sessionId, HelloExtension[] extensions, CipherSuite[] cipherSuites, CompressionMethod[] compressionMethods)
            : base(HandshakeType.ClientHello, version, randomBytes, sessionId, extensions)
        {
            SecurityAssert.NotNull(cipherSuites);
            SecurityAssert.SAssert(cipherSuites.Length >= 2 && cipherSuites.Length <= 0xFFFE);
            CipherSuites = cipherSuites;

            SecurityAssert.NotNull(compressionMethods);
            SecurityAssert.SAssert(compressionMethods.Length >= 1 && cipherSuites.Length <= 0xFF);
            CompressionMethods = compressionMethods;
        }
开发者ID:will14smith,项目名称:Crypto,代码行数:11,代码来源:ClientHelloMessage.cs

示例12: ZipOutputStream

 public ZipOutputStream(Stream baseOutputStream)
     : base(baseOutputStream, new Deflater(-1, true))
 {
     entries = new ArrayList();
     crc = new Crc32();
     defaultCompressionLevel = -1;
     curMethod = CompressionMethod.Deflated;
     zipComment = new byte[0];
     crcPatchPos = -1L;
     sizePatchPos = -1L;
     useZip64_ = UseZip64.Dynamic;
 }
开发者ID:ouyh18,项目名称:LteTools,代码行数:12,代码来源:ZipOutputStream.cs

示例13: ZipOutputStream

 public ZipOutputStream(Stream baseOutputStream, int bufferSize)
     : base(baseOutputStream, new Deflater(-1, true), bufferSize)
 {
     _entries = new ArrayList();
     _crc = new Crc32();
     _defaultCompressionLevel = -1;
     _curMethod = CompressionMethod.Deflated;
     _zipComment = new byte[0];
     _crcPatchPos = -1L;
     _sizePatchPos = -1L;
     _useZip64 = UseZip64.Dynamic;
 }
开发者ID:ouyh18,项目名称:LtePlatform,代码行数:12,代码来源:ZipOutputStream.cs

示例14: MakeInMemoryZip

        protected byte[] MakeInMemoryZip(ref byte[] original, CompressionMethod method,
                                         int compressionLevel, int size, string password, bool withSeek)
        {
            MemoryStream ms;

            if (withSeek)
            {
                ms = new MemoryStream();
            }
            else
            {
                ms = new MemoryStreamWithoutSeek();
            }

            using (ZipOutputStream outStream = new ZipOutputStream(ms))
            {
                outStream.Password = password;

                if (method != CompressionMethod.Stored)
                {
                    outStream.SetLevel(compressionLevel); // 0 - store only to 9 - means best compression
                }

                ZipEntry entry = new ZipEntry("dummyfile.tst");
                entry.CompressionMethod = method;

                outStream.PutNextEntry(entry);

                if (size > 0)
                {
                    System.Random rnd = new Random();
                    original = new byte[size];
                    rnd.NextBytes(original);

                    // Although this could be written in one chunk doing it in lumps
                    // throws up buffering problems including with encryption the original
                    // source for this change.
                    int index = 0;
                    while (size > 0)
                    {
                        int count = (size > 0x200) ? 0x200 : size;
                        outStream.Write(original, index, count);
                        size -= 0x200;
                        index += count;
                    }
                }
            }
            return ms.ToArray();
        }
开发者ID:rollingthunder,项目名称:slsharpziplib,代码行数:49,代码来源:ZipBase.cs

示例15: GetExtensionWithoutCompression

        /// <summary>
        /// Returns the file extension by stripping of the extension of the
        /// compressed file, if any.
        /// </summary>
        public static void GetExtensionWithoutCompression(Uri uri, out string path, out string extension, out CompressionMethod compressionMethod)
        {
            path = GetPathFromUri(uri);
            extension = Path.GetExtension(path);

            if (Constants.CompressionExtensions.ContainsKey(extension))
            {
                compressionMethod = Constants.CompressionExtensions[extension];
                path = Path.GetFileNameWithoutExtension(path);
                extension = Path.GetExtension(path);
            }
            else
            {
                compressionMethod = CompressionMethod.None;
            }
        }
开发者ID:horvatferi,项目名称:graywulf,代码行数:20,代码来源:FileFormatFactory.cs


注:本文中的CompressionMethod类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。