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


C# Zlib.GZipStream类代码示例

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


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

示例1: Execute

			public override void Execute(object parameter)
			{
				var saveFile = new SaveFileDialog
				{
					DefaultExt = ".raven.dump",
					Filter = "Raven Dumps|*.raven.dump"
				};
				var dialogResult = saveFile.ShowDialog() ?? false;

				if (!dialogResult)
					return;

				stream = saveFile.OpenFile();
				gZipStream = new GZipStream(stream, CompressionMode.Compress);
				streamWriter = new StreamWriter(gZipStream);
				jsonWriter = new JsonTextWriter(streamWriter)
				{
					Formatting = Formatting.Indented
				};

				output(string.Format("Exporting to {0}", saveFile.SafeFileName));

				output("Begin reading indexes");

				jsonWriter.WriteStartObject();
				jsonWriter.WritePropertyName("Indexes");
				jsonWriter.WriteStartArray();

				ReadIndexes(0).Catch(exception => Infrastructure.Execute.OnTheUI(() => Finish(exception)));
			}
开发者ID:emertechie,项目名称:ravendb,代码行数:30,代码来源:ExportTask.cs

示例2: Compress

        static string Compress(string fname, bool forceOverwrite)
        {
            var outFname = fname + ".gz";
            if (File.Exists(outFname))
            {
                if (forceOverwrite)
                    File.Delete(outFname);
                else
                    return null;
            }

            using (var fs = File.OpenRead(fname))
            {
                using (var output = File.Create(outFname))
                {
                    using (var compressor = new Ionic.Zlib.GZipStream(output, Ionic.Zlib.CompressionMode.Compress))
                    {
                        compressor.FileName = fname;
                        var fi = new FileInfo(fname);
                        compressor.LastModified = fi.LastWriteTime;
                        Pump(fs, compressor);
                    }
                }
            }
            return outFname;
        }
开发者ID:nithinphilips,项目名称:SMOz,代码行数:26,代码来源:GZip.cs

示例3: Execute

		public override void Execute(object parameter)
		{
			var saveFile = new SaveFileDialog
						   {
							   /*TODO, In Silverlight 5: DefaultFileName = string.Format("Dump of {0}, {1}", ApplicationModel.Database.Value.Name, DateTimeOffset.Now.ToString()), */
							   DefaultExt = ".raven.dump",
							   Filter = "Raven Dumps|*.raven.dump",
						   };

			if (saveFile.ShowDialog() != true)
				return;

			stream = saveFile.OpenFile();
			gZipStream = new GZipStream(stream, CompressionMode.Compress);
			streamWriter = new StreamWriter(gZipStream);
			jsonWriter = new JsonTextWriter(streamWriter)
						 {
							 Formatting = Formatting.Indented
						 };

			output(String.Format("Exporting to {0}", saveFile.SafeFileName));

			output("Begin reading indexes");

			jsonWriter.WriteStartObject();
			jsonWriter.WritePropertyName("Indexes");
			jsonWriter.WriteStartArray();

			ReadIndexes(0).Catch(exception => Infrastructure.Execute.OnTheUI(() => Finish(exception)));
		}
开发者ID:NuvemNine,项目名称:ravendb,代码行数:30,代码来源:ExportDatabaseCommand.cs

示例4: Decompress

        /// <summary>
        /// Decompresses the file at the given path. Returns the path of the
        /// decompressed file.
        /// </summary>
        /// <param name="path">The path to decompress.</param>
        /// <returns>The path of the decompressed file.</returns>
        public string Decompress(string path)
        {
            string outputPath = Regex.Replace(path, @"\.gz$", String.Empty, RegexOptions.IgnoreCase);

            if (File.Exists(outputPath))
            {
                File.Delete(outputPath);
            }

            using (FileStream fs = File.OpenRead(path))
            {
                using (FileStream output = File.Create(outputPath))
                {
                    using (GZipStream gzip = new GZipStream(fs, CompressionMode.Decompress))
                    {
                        byte[] buffer = new byte[4096];
                        int count = 0;

                        while (0 < (count = gzip.Read(buffer, 0, buffer.Length)))
                        {
                            output.Write(buffer, 0, count);
                        }
                    }
                }
            }

            return outputPath;
        }
开发者ID:ChadBurggraf,项目名称:sthreeql,代码行数:34,代码来源:GZipCompressor.cs

示例5: Compress

        /// <summary>
        /// Compresses the file at the given path. Returns the path to the
        /// compressed file.
        /// </summary>
        /// <param name="path">The path to compress.</param>
        /// <returns>The path of the compressed file.</returns>
        public string Compress(string path)
        {
            string outputPath = String.Concat(path, ".gz");

            if (File.Exists(outputPath))
            {
                File.Delete(outputPath);
            }

            using (FileStream fs = File.OpenRead(path))
            {
                using (FileStream output = File.Create(outputPath))
                {
                    using (GZipStream gzip = new GZipStream(output, CompressionMode.Compress, CompressionLevel.BestCompression))
                    {
                        byte[] buffer = new byte[4096];
                        int count = 0;

                        while (0 < (count = fs.Read(buffer, 0, buffer.Length)))
                        {
                            gzip.Write(buffer, 0, count);
                        }
                    }
                }
            }

            return outputPath;
        }
开发者ID:ChadBurggraf,项目名称:sthreeql,代码行数:34,代码来源:GZipCompressor.cs

示例6: Compress

        /// <summary>
        /// 지정된 데이타를 압축한다.
        /// </summary>
        /// <param name="input">압축할 Data</param>
        /// <returns>압축된 Data</returns>
        public override byte[] Compress(byte[] input) {
            if(IsDebugEnabled)
                log.Debug(CompressorTool.SR.CompressStartMsg);

            // check input data
            if(input.IsZeroLength()) {
                if(IsDebugEnabled)
                    log.Debug(CompressorTool.SR.InvalidInputDataMsg);

                return CompressorTool.EmptyBytes;
            }

            byte[] output;

            using(var outStream = new MemoryStream(input.Length)) {
                using(var gzip = new GZipStream(outStream, CompressionMode.Compress)) {
                    gzip.Write(input, 0, input.Length);
                }
                output = outStream.ToArray();
            }

            if(IsDebugEnabled)
                log.Debug(CompressorTool.SR.CompressResultMsg, input.Length, output.Length, output.Length / (double)input.Length);

            return output;
        }
开发者ID:debop,项目名称:NFramework,代码行数:31,代码来源:IonicGZipCompressor.cs

示例7: uncompress

        public void uncompress(Stream inStream, Stream outStream)
        {

            GZipStream compressionStream = new GZipStream(inStream, CompressionMode.Decompress, true);

            compressionStream.CopyTo(outStream);

        }
开发者ID:superkaka,项目名称:mycsharp,代码行数:8,代码来源:GZipCompresser.cs

示例8: Decompress

 public byte[] Decompress(Stream inputStream)
 {
     using (var gzipStream = new GZipStream(inputStream, CompressionMode.Decompress))
     using (var outputStream = new MemoryStream())
     {
         gzipStream.WriteTo(outputStream);
         return outputStream.ToArray();
     }
 }
开发者ID:ryanwentzel,项目名称:DesignPatterns,代码行数:9,代码来源:GZipCompression.cs

示例9: Execute

		public override void Execute(object parameter)
		{
            TaskCheckBox attachmentUI = taskModel.TaskInputs.FirstOrDefault(x => x.Name == "Include Attachments") as TaskCheckBox;
            includeAttachments = attachmentUI != null && attachmentUI.Value;

			var saveFile = new SaveFileDialog
			{
				DefaultExt = ".ravendump",
				Filter = "Raven Dumps|*.ravendump;*.raven.dump",
			};

			var name = ApplicationModel.Database.Value.Name;
			var normalizedName = new string(name.Select(ch => Path.GetInvalidPathChars().Contains(ch) ? '_' : ch).ToArray());
			var defaultFileName = string.Format("Dump of {0}, {1}", normalizedName, DateTimeOffset.Now.ToString("dd MMM yyyy HH-mm", CultureInfo.InvariantCulture));
			try
			{
				saveFile.DefaultFileName = defaultFileName;
			}
			catch { }

			if (saveFile.ShowDialog() != true)
				return;

			taskModel.CanExecute.Value = false;

			stream = saveFile.OpenFile();
			gZipStream = new GZipStream(stream, CompressionMode.Compress);
			streamWriter = new StreamWriter(gZipStream);
			jsonWriter = new JsonTextWriter(streamWriter)
			{
				Formatting = Formatting.Indented
			};
			taskModel.TaskStatus = TaskStatus.Started;

			output(String.Format("Exporting to {0}", saveFile.SafeFileName));
			jsonWriter.WriteStartObject();

		    Action finalized = () => 
            {
                jsonWriter.WriteEndObject();
                Infrastructure.Execute.OnTheUI(() => Finish(null));
		    };

		    Action readAttachments = () => ReadAttachments(Guid.Empty, 0, callback: finalized);
		    Action readDocuments = () => ReadDocuments(Guid.Empty, 0, callback: includeAttachments ? readAttachments : finalized);

            try
            {
                ReadIndexes(0, callback: readDocuments);
            }
            catch (Exception ex)
            {
                taskModel.ReportError(ex);
				Infrastructure.Execute.OnTheUI(() => Finish(ex));
            }
		}
开发者ID:XpressiveCode,项目名称:ravendb,代码行数:56,代码来源:ExportDatabaseCommand.cs

示例10: compress

        public void compress(Stream inStream, Stream outStream)
        {

            GZipStream compressionStream = new GZipStream(outStream, CompressionMode.Compress, true);

            inStream.CopyTo(compressionStream);

            compressionStream.Close();

        }
开发者ID:superkaka,项目名称:mycsharp,代码行数:10,代码来源:GZipCompresser.cs

示例11: compress

        static public byte[] compress(byte[] bytes)
        {

            var output = new MemoryStream();
            var gzipStream = new GZipStream(output, CompressionMode.Compress, true);
            gzipStream.Write(bytes, 0, bytes.Length);
            gzipStream.Close();
            return output.ToArray();

        }
开发者ID:superkaka,项目名称:LibForUnity,代码行数:10,代码来源:GZipCompresser.cs

示例12: Compress

 public static void Compress(byte[] data, string path)
 {
     using (GZipStream gzip = new GZipStream(
         new FileStream(path, FileMode.Create, FileAccess.Write),
         CompressionMode.Compress, CompressionLevel.BestCompression,
         false))
     {
         gzip.Write(data, 0, data.Length);
         gzip.Flush();
     }
 }
开发者ID:Ravenheart,项目名称:driversolutions,代码行数:11,代码来源:Tools.cs

示例13: CompressGzip

        public static byte[] CompressGzip(byte[] bytes)
        {
            using (var ms = new MemoryStream())
            {
                using (var zip = new GZipStream(ms, CompressionMode.Compress, true))
                {
                    zip.Write(bytes, 0, bytes.Length);
                }

                return ms.ToArray();
            }
        }
开发者ID:venusdharan,项目名称:Titanium-Web-Proxy,代码行数:12,代码来源:Compression.cs

示例14: Main

        public static int Main(string[] args)
        {
            var inputFile = args[0];
            var targetFolder = args[1];

            if (!Directory.Exists(targetFolder))
                Directory.CreateDirectory(targetFolder);

            var language = _GetLanguage(args);
            var type = _GetGramType(args);
            var fictionOnly = args.Any(x => x.ToLower() == "fiction");
            var versionDate = args.Single(x => x.All(Char.IsNumber));
            var includeDependencies = args.Any(x => x.ToLower() == "include0");

            var rawHrefs = File.ReadAllLines(inputFile).Select(_GetHref).Where(x => x != null).Select(x => x.ToLower());
            var filtered = rawHrefs
                .Where(x => x.Contains(_GetNGramTypeForFilter(type).ToLower()))
                .Where(x => _FilterByLanguage(x, language))
                .Where(x => x.Contains(versionDate)).ToArray();

            var connectionString = @"Data Source=.\mssql12;Initial Catalog=NGram;Integrated Security=True";

            var oneGramLoader = new OneGramLoader();

            foreach (var rawHref in filtered)
            {
                Console.WriteLine("Downloading href {0}", rawHref);
                var req = WebRequest.CreateHttp(rawHref);
                var res = req.GetResponse();
                using (var resStream = res.GetResponseStream())
                {
                    using (var zipStream = new GZipStream(resStream, CompressionMode.Decompress))
                    {
                        using (var sr = new StreamReader(zipStream))
                        {
                            oneGramLoader.ProcessOneGram(sr, connectionString);
                        }

                        zipStream.Close();
                    }
                    resStream.Close();
                }
            }

            Console.WriteLine("Finished - any key");
            Console.ReadLine();

            return 0;
        }
开发者ID:erick-thompson,项目名称:BookNGram,代码行数:49,代码来源:Program.cs

示例15: TwitterLinkBuilder

        public string TwitterLinkBuilder(string q)
        {
            string ret = string.Empty;
            JArray output = new JArray();
            SortedDictionary<string, string> requestParameters = new SortedDictionary<string, string>();
            try
            {
                var oauth_url = " https://api.twitter.com/1.1/search/tweets.json?q=" + q.Trim() + "&result_type=recent";
                var headerFormat = "Bearer {0}";
                var authHeader = string.Format(headerFormat, "AAAAAAAAAAAAAAAAAAAAAOZyVwAAAAAAgI0VcykgJ600le2YdR4uhKgjaMs%3D0MYOt4LpwCTAIi46HYWa85ZcJ81qi0D9sh8avr1Zwf7BDzgdHT");

                var postBody = requestParameters.ToWebString();
                ServicePointManager.Expect100Continue = false;

                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(oauth_url + "?"
                       + requestParameters.ToWebString());

                request.Headers.Add("Authorization", authHeader);
                request.Method = "GET";
                request.Headers.Add("Accept-Encoding", "gzip");
                HttpWebResponse response = request.GetResponse() as HttpWebResponse;
                Stream responseStream = new GZipStream(response.GetResponseStream(), CompressionMode.Decompress);
                using (var reader = new StreamReader(responseStream))
                {
                    var objText = reader.ReadToEnd();
                    output = JArray.Parse(JObject.Parse(objText)["statuses"].ToString());
                }
                List<string> _lst = new List<string>();
                foreach (var item in output)
                {
                    try
                    {
                        string _urls = item["entities"]["urls"][0]["expanded_url"].ToString();
                        if (!string.IsNullOrEmpty(_urls))
                            _lst.Add(_urls);
                    }
                    catch { }
                }

                ret = new JavaScriptSerializer().Serialize(_lst);
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
                ret = "";
            }

            return ret; 
        }
开发者ID:prog-moh,项目名称:socioboard-core,代码行数:49,代码来源:LinkBuilder.asmx.cs


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