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


C# DeflaterOutputStream.Close方法代码示例

本文整理汇总了C#中ICSharpCode.SharpZipLib.Zip.Compression.Streams.DeflaterOutputStream.Close方法的典型用法代码示例。如果您正苦于以下问题:C# DeflaterOutputStream.Close方法的具体用法?C# DeflaterOutputStream.Close怎么用?C# DeflaterOutputStream.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ICSharpCode.SharpZipLib.Zip.Compression.Streams.DeflaterOutputStream的用法示例。


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

示例1: Compress

        public byte[] Compress(byte[] bytData, params int[] ratio)
        {
            int compRatio = 9;
            try
            {
                if (ratio[0] > 0)

                {
                    compRatio = ratio[0];
                }
            }
            catch
            {
                throw;
            }

            try
            {
                var ms = new MemoryStream();
                var defl = new Deflater(compRatio, false);
                Stream s = new DeflaterOutputStream(ms, defl);
                s.Write(bytData, 0, bytData.Length);
                s.Close();
                byte[] compressedData = ms.ToArray();
                 return compressedData;
            }
            catch
            {
                throw;

            }
        }
开发者ID:jojozhuang,项目名称:Study,代码行数:32,代码来源:Wrapper.cs

示例2: Compress

		// netz.compress.ICompress implementation

		public long Compress(string file, string zipFile)
		{
			long length = -1;
			FileStream ifs = null;
			FileStream ofs = null;
			try
			{
				ifs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read);
				ofs = File.Open(zipFile, FileMode.Create, FileAccess.Write, FileShare.None);
				DeflaterOutputStream dos = new DeflaterOutputStream(ofs, new Deflater(Deflater.BEST_COMPRESSION));
				byte[] buff = new byte[ifs.Length];
				while(true)
				{
					int r = ifs.Read(buff, 0, buff.Length);
					if(r <= 0) break;
					dos.Write(buff, 0, r);
				}
				dos.Flush();
				dos.Finish();
				length = dos.Length;
				dos.Close();
			}
			finally
			{
				if(ifs != null) ifs.Close();
				if(ofs != null) ofs.Close();
			}
			return length;
		}
开发者ID:transformersprimeabcxyz,项目名称:_TO-DO-msnet-netz-compressor-madebits,代码行数:31,代码来源:defcomp.cs

示例3: Deflate

 internal static byte[] Deflate(byte[] buffer)
 {
     MemoryStream compressedBufferStream = new MemoryStream();
     DeflaterOutputStream deflaterStream = new DeflaterOutputStream(compressedBufferStream);
     deflaterStream.Write(buffer, 0, buffer.Length);
     deflaterStream.Close();
     return compressedBufferStream.ToArray();
 }
开发者ID:kkkkyue,项目名称:FtexTool,代码行数:8,代码来源:ZipUtility.cs

示例4: Compress

 public static byte[] Compress(byte[] bytes)
 {
     MemoryStream memory = new MemoryStream();
     DeflaterOutputStream stream = new DeflaterOutputStream(memory, new Deflater(Deflater.BEST_COMPRESSION), 131072);
     stream.Write(bytes, 0, bytes.Length);
     stream.Close();
     return memory.ToArray();
 }
开发者ID:mex868,项目名称:Nissi.Solution,代码行数:8,代码来源:Zip.cs

示例5: Compress

 public static byte[] Compress(byte[] Data)
 {
     MemoryStream ms = new MemoryStream();
     Stream s = new DeflaterOutputStream(ms);
     s.Write(Data, 0, Data.Length);
     s.Close();
     return ms.ToArray();
 }
开发者ID:remixod,项目名称:NetLibClient,代码行数:8,代码来源:Compression.cs

示例6: Compress

 public byte[] Compress( byte[] bytes )
 {
     MemoryStream memory = new MemoryStream();
     Stream stream = new DeflaterOutputStream( memory,
         new ICSharpCode.SharpZipLib.Zip.Compression.Deflater(
         ICSharpCode.SharpZipLib.Zip.Compression.Deflater.BEST_COMPRESSION ), 131072 );
     stream.Write( bytes, 0, bytes.Length );
     stream.Close();
     return memory.ToArray();
 }
开发者ID:popovegor,项目名称:gt,代码行数:10,代码来源:GTCommonWebPage.cs

示例7: Encode

        public override byte[] Encode(byte[] data)
        {
            var o = new MemoryStream();

            var compressed = new DeflaterOutputStream(o, new Deflater(1));
            compressed.Write(data, 0, data.Length);
            compressed.Flush();
            compressed.Close();

            return o.ToArray();
        }
开发者ID:ademar,项目名称:melon-reports,代码行数:11,代码来源:FlateFilter.cs

示例8: Compress

        public string Compress(string uncompressedString)
        {
            var stringAsBytes = Encoding.UTF8.GetBytes(uncompressedString);
            var ms = new MemoryStream();
            var outputStream = new DeflaterOutputStream(ms);
            outputStream.Write(stringAsBytes, 0, stringAsBytes.Length);
            outputStream.Close();
            var compressedData = ms.ToArray();

            return Convert.ToBase64String(compressedData, 0, compressedData.Length);
        }
开发者ID:benaston,项目名称:NCacheFacade,代码行数:11,代码来源:SharpZipStringCompressor.cs

示例9: Compress

        /// <summary>
        /// Compress an array of bytes.
        /// </summary>
        /// <param name="_pBytes">An array of bytes to be compressed.</param>
        /// <returns>Compressed bytes.</returns>
        /// <example>
        /// Following example demonstrates the way of compressing an ASCII string text.
        /// <code>
        /// public void Compress()
        /// {
        ///     string source = "Hello, world!";
        ///     byte[] source_bytes = System.Text.Encoding.ASCII.GetBytes(source);
        ///     byte[] compressed = DataCompression.Compress(source_bytes);
        ///     
        ///     // Process the compressed bytes here.
        /// }
        /// </code>
        /// </example>
        /// <remarks>It is the best practice that use the overrided <b>DataCompression.Compress</b> method with <see cref="System.String"/> parameter to compress a string.</remarks>
        public static byte[] Compress(byte[] _pBytes)
        {
            MemoryStream ms = new MemoryStream();

            Deflater mDeflater = new Deflater(Deflater.BEST_COMPRESSION);
            DeflaterOutputStream outputStream = new DeflaterOutputStream(ms, mDeflater, 131072);

            outputStream.Write(_pBytes, 0, _pBytes.Length);
            outputStream.Close();

            return ms.ToArray();
        }
开发者ID:daxnet,项目名称:guluwin,代码行数:31,代码来源:DataCompression.cs

示例10: Compress

        public static byte[] Compress(byte[] data)
        {
            byte[] result = null;

            using (MemoryStream ms = new MemoryStream())
                using (Stream s = new DeflaterOutputStream(ms))
                {
                    s.Write(data, 0, data.Length);
                    s.Close();
                    result = ms.ToArray();
                }

            return result;
        }
开发者ID:hollow87,项目名称:Arca4,代码行数:14,代码来源:ZipLib.cs

示例11: Deflate

		internal static Byte[] Deflate(Byte[] b)
		{
			System.IO.MemoryStream ms = new System.IO.MemoryStream();
			DeflaterOutputStream outStream =new DeflaterOutputStream( ms);
			
			outStream.Write(b, 0, b.Length);
			outStream.Flush();
			outStream.Finish();
			
			Byte[] result=ms.ToArray();
			outStream.Close();
			ms.Close();
			return result;
		}
开发者ID:maanshancss,项目名称:ClassLibrary,代码行数:14,代码来源:Utility.cs

示例12: Compress

    public static string Compress(byte[] data)
    {
        using(var m = new MemoryStream())
        {
            switch(technique)
            {
            case "ZipStream":

                var br = new BinaryWriter(m);
                var z = new DeflaterOutputStream(m);
                br.Write(data.Length);
                z.Write(data, 0, data.Length);
                z.Flush();
                z.Close();
                break;
            }
            return technique + ":" + Convert.ToBase64String(m.GetBuffer());
        }
    }
开发者ID:Bloodcoder,项目名称:unityserializer-ng,代码行数:19,代码来源:SevenZipHelper.cs

示例13: Deflate

        public byte[] Deflate(string text)
        {
            var buffer = Encoding.UTF8.GetBytes(text);
            using (var ms = new MemoryStream())
            {
                using (var zipStream = new DeflaterOutputStream(ms, new Deflater(9)))
                {
                    zipStream.Write(buffer, 0, buffer.Length);
                    zipStream.Close();

                    var compressed = ms.ToArray();

                    var gzBuffer = new byte[compressed.Length + 4];
                    Buffer.BlockCopy(compressed, 0, gzBuffer, 4, compressed.Length);
                    Buffer.BlockCopy(BitConverter.GetBytes(buffer.Length), 0, gzBuffer, 0, 4);

                    return gzBuffer;
                }
            }
        }
开发者ID:EvgeniyProtas,项目名称:servicestack,代码行数:20,代码来源:ICSharpDeflateProvider.cs

示例14: Compress

	public static string Compress(byte[] data, ICodeProgress progress)
	{
		using(var m = new MemoryStream())
		{
			switch(technique)
			{
			case "ZipStream":
				
				var br = new BinaryWriter(m);
				var z = new DeflaterOutputStream(m);
				br.Write(data.Length);
				z.Write(data, 0, data.Length);
				z.Flush();
				z.Close();
				break;
			case "7Zip":
			default:
				return Convert.ToBase64String(SevenZipRadical.Compression.LZMA.SevenZipRadicalHelper.Compress(data, progress));
			}
			return technique + ":" + Convert.ToBase64String(m.GetBuffer());
		}
	}
开发者ID:MHaubenstock,项目名称:RPG-Board-3D,代码行数:22,代码来源:SevenZipHelper.cs

示例15: Compress

 public static string Compress(byte[] data)
 {
     string result;
     using (MemoryStream memoryStream = new MemoryStream())
     {
         string text = CompressionHelper.technique;
         if (text != null)
         {
             if (CompressionHelper.<>f__switch$map1F == null)
             {
                 CompressionHelper.<>f__switch$map1F = new Dictionary<string, int>(1)
                 {
                     {
                         "ZipStream",
                         0
                     }
                 };
             }
             int num;
             if (CompressionHelper.<>f__switch$map1F.TryGetValue(text, out num))
             {
                 if (num == 0)
                 {
                     BinaryWriter binaryWriter = new BinaryWriter(memoryStream);
                     DeflaterOutputStream deflaterOutputStream = new DeflaterOutputStream(memoryStream);
                     binaryWriter.Write(data.Length);
                     deflaterOutputStream.Write(data, 0, data.Length);
                     deflaterOutputStream.Flush();
                     deflaterOutputStream.Close();
                 }
             }
         }
         result = CompressionHelper.technique + ":" + Convert.ToBase64String(memoryStream.GetBuffer());
     }
     return result;
 }
开发者ID:GameDiffs,项目名称:TheForest,代码行数:36,代码来源:CompressionHelper.cs


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