當前位置: 首頁>>代碼示例>>C#>>正文


C# SevenZipCompressor.CompressStream方法代碼示例

本文整理匯總了C#中SevenZip.SevenZipCompressor.CompressStream方法的典型用法代碼示例。如果您正苦於以下問題:C# SevenZipCompressor.CompressStream方法的具體用法?C# SevenZipCompressor.CompressStream怎麽用?C# SevenZipCompressor.CompressStream使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在SevenZip.SevenZipCompressor的用法示例。


在下文中一共展示了SevenZipCompressor.CompressStream方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: SerializationDemo

		public void SerializationDemo(){
			ArgumentException ex = new ArgumentException("blahblah");
			System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bf =
				new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
			using (MemoryStream ms = new MemoryStream()) {
				bf.Serialize(ms, ex);
				SevenZipCompressor cmpr = new SevenZipCompressor();
				cmpr.CompressStream(ms, File.Create(createTempFileName()));
			}
		}
開發者ID:KOLANICH,項目名稱:SevenZipSharp,代碼行數:10,代碼來源:SevenZipTestPack.cs

示例2: Compress

        public int Compress(PointCloudTile tile, byte[] uncompressedBuffer, int count, byte[] compressedBuffer)
        {
            SevenZipCompressor compressor = new SevenZipCompressor
            {
                CompressionMethod = SevenZip.CompressionMethod.Lzma2,
                CompressionLevel = CompressionLevel.Fast
            };

            MemoryStream uncompressedStream = new MemoryStream(uncompressedBuffer, 0, count, false);

            // custom stream is required because the position is always 32 instead of the end of the stream
            MemorableMemoryStream compressedStream = new MemorableMemoryStream(compressedBuffer);

            compressor.CompressStream(uncompressedStream, compressedStream);

            return (int)compressedStream.MaxPosition;
        }
開發者ID:jdauie,項目名稱:cloudae,代碼行數:17,代碼來源:SevenZipSharp.cs

示例3: Compress

        /// <summary>
        /// 壓縮字節數組
        /// </summary>
        /// <param name="input">字節數組</param>
        /// <returns>壓縮後的字節數組</returns>
        public static byte[] Compress(byte[] input)
        {
            byte[] compressed = null;
            SevenZipCompressor compressor = new SevenZipCompressor();
            compressor.CompressionMethod = CompressionMethod.Ppmd;
            compressor.CompressionLevel = CompressionLevel.High;
            using (MemoryStream ms = new MemoryStream(input))
            {
                using (MemoryStream outMs = new MemoryStream())
                {
                    compressor.CompressStream(ms, outMs);
                    outMs.Position = 0;
                    compressed = new byte[outMs.Length];
                    outMs.Read(compressed, 0, compressed.Length);
                }
            }

            return compressed;
        }
開發者ID:Oman,項目名稱:Maleos,代碼行數:24,代碼來源:StringCompress.cs

示例4: CompressBytes

		public static byte[] CompressBytes(byte[] data)
	    {
	        byte[] compressedData = null;
	
	        SevenZipCompressor compressor = new SevenZipCompressor();
	        compressor.CompressionMethod = CompressionMethod.Ppmd;
	        compressor.CompressionLevel = SevenZip.CompressionLevel.Ultra;
	        compressor.ScanOnlyWritable = true;
	        compressor.DefaultItemName = "T";
	
	        using (MemoryStream msin = new MemoryStream(data))
	        {
	            using (MemoryStream msout = new MemoryStream())
	            {
	                compressor.CompressStream(msin, msout);	
	                compressedData = msout.ToArray();
	            }
	        }
	
	        return compressedData;
	    }
開發者ID:AluminumDev,項目名稱:WinBXB,代碼行數:21,代碼來源:7ZipCompressor.cs

示例5: 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

示例6: HandleRequest

        public override void HandleRequest(string jsonString, AjaxBase ajax)
        {
            CheckOtherComponentRequest request = Utility.ParseJson<CheckOtherComponentRequest>(jsonString);

            CheckOtherComponentResponse response = new CheckOtherComponentResponse();
            response.pass = false;

            try
            {
                switch (request.component)
                {
                    case 0:
                        SevenZipBase.SetLibraryPath(request.path);
                        SevenZipCompressor c = new SevenZipCompressor();
                        using (System.IO.MemoryStream m1 = new MemoryStream())
                        {
                            using (System.IO.MemoryStream m2 = new MemoryStream())
                            {
                                byte[] b = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
                                m1.Write(b, 0, b.Length);
                                c.CompressStream(m1, m2);
                            }
                        }

                        response.pass = true;
                        break;
                    default:
                        break;
                }
            }
            catch (Exception)
            {
            }

            ajax.ReturnJson(response);
        }
開發者ID:a-fung,項目名稱:MangaWeb3,代碼行數:36,代碼來源:CheckOtherComponentRequestHandler.cs

示例7: CompressionBenchmark

 private static bool CompressionBenchmark(Stream inStream, Stream outStream,
     OutArchiveFormat format, CompressionMethod method,
     ref LibraryFeature? features, LibraryFeature testedFeature)
 {
     try
     {
         var compr = new SevenZipCompressor { ArchiveFormat = format, CompressionMethod = method };
         compr.CompressStream(inStream, outStream);
     }
     catch (Exception)
     {
         return false;
     }
     features |= testedFeature;
     return true;
 }
開發者ID:dreamxstudio,項目名稱:7zipDecrypt-Kr,代碼行數:16,代碼來源:LibraryManager.cs

示例8: CompressStreamExternalTest

		public void CompressStreamExternalTest(){
			var tmp = new SevenZipCompressor();
			tmp.CompressStream(
				File.OpenRead(testFile1),
				File.Create(Path.Combine(tempFolder, TestContext.TestName + ".7z"))
				);
		}
開發者ID:KOLANICH,項目名稱:SevenZipSharp,代碼行數:7,代碼來源:SevenZipTestPack.cs

示例9: Compress

 protected long Compress(SevenZipCompressor compressor, AlignedReadStream readStream, AlignedWriteStream writeStream,
     string password)
 {
     using (MaxPositionStream maxWriteStream = new MaxPositionStream(writeStream))
     {
         if (string.IsNullOrEmpty(password))
         {
             compressor.CompressStream(readStream, maxWriteStream);
         }
         else
         {
             compressor.CompressStream(readStream, maxWriteStream, password);
         }
         return maxWriteStream.MaxPosition;
     }
 }
開發者ID:simony,項目名稱:WinUtils,代碼行數:16,代碼來源:LocalArch.cs

示例10: Compress

 private void Compress(ref byte[] input)
 {
     SevenZipCompressor compressor = new SevenZipCompressor();
     compressor.CompressionMethod = CompressionMethod.Lzma;
     compressor.CompressionLevel = CompressionLevel.Ultra;
     using (MemoryStream msin = new MemoryStream(input))
     using (MemoryStream msout = new MemoryStream())
     {
         compressor.CompressStream(msin, msout);
         msout.Position = 0;
         input = new byte[msout.Length];
         msout.Read(input, 0, input.Length);
     }
 }
開發者ID:jerrybird,項目名稱:SISCell-1,代碼行數:14,代碼來源:PACK.cs

示例11: Zipp

        public bool Zipp(IEnumerable<string> iText, string iFileName, string iPassword)
        {
            CheckArguments(iText, iFileName);

            SevenZipCompressor sevenZipCompressor = new SevenZipCompressor()
            {
                DirectoryStructure = true,
                EncryptHeaders = true,
                DefaultItemName = "Default.txt"
            };

            try
            {
                using (var instream = new MemoryStream())
                {
                    using (var streamwriter = new StreamWriter(instream) { AutoFlush = true })
                    {
                        iText.Apply(t => streamwriter.WriteLine(t));
                        instream.Position = 0;
                        using (Stream outstream = File.Create(iFileName))
                        {
                            sevenZipCompressor.CompressStream(instream, outstream, iPassword);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Trace.WriteLine(string.Format("Problem zipping a text: {0}", e));
                return false;
            }

            return true;
        }
開發者ID:David-Desmaisons,項目名稱:MusicCollection,代碼行數:34,代碼來源:SevenZipZipper.cs


注:本文中的SevenZip.SevenZipCompressor.CompressStream方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。