• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# CompressionMethod类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: GetFileFormatDescription

        public FileFormatDescription GetFileFormatDescription(Uri uri, out string path, out string extension, out CompressionMethod compression)
        {
            GetExtensionWithoutCompression(uri, out path, out extension, out compression);

            // FInd file format with the appropriate extensions
            FileFormatDescription format = null;
            foreach (var f in GetFileFormatDescriptions())
            {
                if (StringComparer.InvariantCultureIgnoreCase.Compare(extension, f.Value.DefaultExtension) == 0)
                {
                    format = f.Value;
                    break;
                }
            }

            return format;
        }
开发者ID:horvatferi,项目名称:graywulf,代码行数:17,代码来源:FileFormatFactory.cs


示例17: CompressionServerChannelSinkProvider

        /// <summary>
        /// Initializes a new instance of the <see cref="CompressionServerChannelSinkProvider"/> class.
        /// </summary>
        /// <param name="properties">Compression sink properties.</param>
        /// <param name="providerData">The provider data (ignored).</param>
        public CompressionServerChannelSinkProvider(IDictionary properties, ICollection providerData)
        {
            // read in web.config parameters
            foreach (DictionaryEntry entry in properties)
            {
                switch ((string)entry.Key)
                {
                    case "compressionThreshold":
                        _compressionThreshold = Convert.ToInt32((string)entry.Value);
                        break;

                    case "compressionMethod":
                        _compressionMethod = (CompressionMethod)Enum.Parse(typeof(CompressionMethod), (string)entry.Value);
                        break;

                    default:
                        throw new ArgumentException("Invalid configuration entry: " + (string)entry.Key);
                }
            }
        }
开发者ID:yallie,项目名称:zyan,代码行数:25,代码来源:CompressionServerChannelSinkProvider.cs


示例18: CompressBytes

        public static byte[] CompressBytes(byte[] data,
            CompressionLevel CompressionLevel,
            CompressionMethod CompressionMethod = CompressionMethod.Default
            )
        {
            Inits.EnsureBinaries();

            using (var inStream = new MemoryStream(data))
            {
                using (var outStream = new MemoryStream())
                {
                    var compressor = new SevenZipCompressor();
                    compressor.CompressionLevel = (SevenZip.CompressionLevel)(int)CompressionLevel;
                    compressor.CompressionMethod = (SevenZip.CompressionMethod)(int)CompressionMethod;
                    compressor.ScanOnlyWritable = true;
                    compressor.CompressStream(inStream, outStream);

                    return outStream.ToArray();
                }
            }
        }
开发者ID:IsaacSanch,项目名称:KoruptLib,代码行数:21,代码来源:Generic.cs


示例19: ZipEntry

        /// <summary>
        /// Initializes an entry with the given name and made by information
        /// </summary>
        /// <param name="name">Name for this entry</param>
        /// <param name="madeByInfo">Version and HostSystem Information</param>
        /// <param name="versionRequiredToExtract">Minimum required zip feature version required to extract this entry</param>
        /// <param name="method">Compression method for this entry.</param>
        /// <exception cref="ArgumentNullException">
        /// The name passed is null
        /// </exception>
        /// <exception cref="ArgumentOutOfRangeException">
        /// versionRequiredToExtract should be 0 (auto-calculate) or > 10
        /// </exception>
        /// <remarks>
        /// This constructor is used by the ZipFile class when reading from the central header
        /// It is not generally useful, use the constructor specifying the name only.
        /// </remarks>
        internal ZipEntry(string name, int versionRequiredToExtract, int madeByInfo,
			CompressionMethod method)
        {
            if (name == null) {
                throw new ArgumentNullException(nameof(name));
            }

            if (name.Length > 0xffff) {
                throw new ArgumentException("Name is too long", nameof(name));
            }

            if ((versionRequiredToExtract != 0) && (versionRequiredToExtract < 10)) {
                throw new ArgumentOutOfRangeException(nameof(versionRequiredToExtract));
            }

            this.DateTime = DateTime.Now;
            this.name = CleanName(name);
            this.versionMadeBy = (ushort)madeByInfo;
            this.versionToExtract = (ushort)versionRequiredToExtract;
            this.method = method;
        }
开发者ID:icsharpcode,项目名称:SharpZipLib,代码行数:38,代码来源:ZipEntry.cs


示例20: ProcessAESExtraData

 // For AES the method in the entry is 99, and the real compression method is in the extradata
 //
 private void ProcessAESExtraData(ZipExtraData extraData)
 {
     if (extraData.Find(0x9901)) {
         // Set version and flag for Zipfile.CreateAndInitDecryptionStream
         versionToExtract = ZipConstants.VERSION_AES;            // Ver 5.1 = AES see "Version" getter
                                                                 // Set StrongEncryption flag for ZipFile.CreateAndInitDecryptionStream
         Flags = Flags | (int)GeneralBitFlags.StrongEncryption;
         //
         // Unpack AES extra data field see http://www.winzip.com/aes_info.htm
         int length = extraData.ValueLength;         // Data size currently 7
         if (length < 7)
             throw new ZipException("AES Extra Data Length " + length + " invalid.");
         int ver = extraData.ReadShort();            // Version number (1=AE-1 2=AE-2)
         int vendorId = extraData.ReadShort();       // 2-character vendor ID 0x4541 = "AE"
         int encrStrength = extraData.ReadByte();    // encryption strength 1 = 128 2 = 192 3 = 256
         int actualCompress = extraData.ReadShort(); // The actual compression method used to compress the file
         _aesVer = ver;
         _aesEncryptionStrength = encrStrength;
         method = (CompressionMethod)actualCompress;
     } else
         throw new ZipException("AES Extra Data missing");
 }
开发者ID:icsharpcode,项目名称:SharpZipLib,代码行数:24,代码来源:ZipEntry.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# CompressionMode类代码示例发布时间:2022-05-24
下一篇:
C# CompressionLevel类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap