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


C# GZipStream.CopyToAsync方法代码示例

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


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

示例1: BeforeDeserialization

 public async Task<byte[]> BeforeDeserialization(IEnvelope envelope, byte[] serializedMessage)
 {
     using (var inputStream = new MemoryStream(serializedMessage))
     using (var decompressionStream = new GZipStream(inputStream, CompressionMode.Decompress))
     using (var outputStream = new MemoryStream())
     {
         await decompressionStream.CopyToAsync(outputStream).ConfigureAwait(false);
         return outputStream.ToArray();
     }
 }
开发者ID:Mecabot,项目名称:RedDog,代码行数:10,代码来源:GzipCompressionMessageFilter.cs

示例2: SerializeToStreamAsync

 /// <inheritdoc />
 protected async override Task SerializeToStreamAsync(Stream stream, TransportContext context)
 {
     using (content)
     {
         var compressedStream = await content.ReadAsStreamAsync();
         using (var uncompressedStream = new GZipStream(compressedStream, CompressionMode.Decompress))
         {
             await uncompressedStream.CopyToAsync(stream);
         }
     }
 }
开发者ID:richardschneider,项目名称:spark,代码行数:12,代码来源:GzipCompressedContent.cs

示例3: DecompressAsync

 /// <summary>
 /// Asychronously Decompresses a string using System.IO.Compression.GZipStream
 /// </summary>
 /// <param name="s">String to decompress</param>
 /// <returns>Decompressed string</returns>
 public static async Task<string> DecompressAsync(string s)
 {
     var bytes = Convert.FromBase64String(s);
     using (var msi = new MemoryStream(bytes))
     using (var mso = new MemoryStream())
     {
         using (var gs = new GZipStream(msi, CompressionMode.Decompress))
         {
             await gs.CopyToAsync(mso);
         }
         return Encoding.Unicode.GetString(mso.ToArray());
     }
 }
开发者ID:jeremywho,项目名称:OpenKeyVal.NET,代码行数:18,代码来源:Compression.cs

示例4: DownloadTitles

        /// <summary>
        /// Downloads an xml file from AniDB which contains all of the titles for every anime, and their IDs,
        /// and saves it to disk.
        /// </summary>
        /// <param name="titlesFile">The destination file name.</param>
        private async Task DownloadTitles(string titlesFile)
        {
            _logger.Debug("Downloading new AniDB titles file.");

            var client = new WebClient();

            await AniDbSeriesProvider.RequestLimiter.Tick();

            using (var stream = await client.OpenReadTaskAsync(TitlesUrl))
            using (var unzipped = new GZipStream(stream, CompressionMode.Decompress))
            using (var writer = File.Open(titlesFile, FileMode.Create, FileAccess.Write))
            {
                await unzipped.CopyToAsync(writer).ConfigureAwait(false);
            }
        }
开发者ID:mtlott,项目名称:MediaBrowser.Plugins.Anime,代码行数:20,代码来源:AniDbTitleDownloader.cs

示例5: DecompressAsync

 public static async Task<string> DecompressAsync(string input)
 {
     using (var inputStream = new MemoryStream(Convert.FromBase64String(input)))
     {
         using (var stream = new GZipStream(inputStream, CompressionMode.Decompress))
         {
             using (var outputStream = new MemoryStream())
             {
                 await stream.CopyToAsync(outputStream);
                 var output = outputStream.ToArray();
                 return Encoding.UTF8.GetString(output, 0, output.Length);
             }
         }
     }
 }
开发者ID:JerryBian,项目名称:CommonLibrary4Net,代码行数:15,代码来源:CompressHelper.cs

示例6: WriteFlotAppAsync

 public static async Task WriteFlotAppAsync(Stream output, bool decompress = false)
 {
     if (!decompress)
     {
         using (var stream = Assembly.GetAssembly(typeof(FlotWebApp)).GetManifestResourceStream("Metrics.Visualization.index.full.html.gz"))
         {
             await stream.CopyToAsync(output).ConfigureAwait(false);
         }
     }
     else
     {
         using (var stream = Assembly.GetAssembly(typeof(FlotWebApp)).GetManifestResourceStream("Metrics.Visualization.index.full.html.gz"))
         using (var gzip = new GZipStream(stream, CompressionMode.Decompress))
         {
             await gzip.CopyToAsync(output).ConfigureAwait(false);
         }
     }
 }
开发者ID:dynamicdeploy,项目名称:Metrics.NET,代码行数:18,代码来源:FlotWebApp.cs

示例7: Decrompress

        /// <summary>
        /// Decrompresses Given File
        /// </summary>
        /// <param name="File">File to Decompress</param>
        public static async Task<String> Decrompress(String file)
        {
            FileInfo Info = new FileInfo(file);
            string newFileName;

            using (FileStream originalFileStream = Info.OpenRead())
            {
                string currentFile = Info.FullName;
                 newFileName = currentFile.Remove(currentFile.Length - Info.Extension.Length);

                using (FileStream decompressed = File.Create(newFileName))
                {
                    using (GZipStream decompression = new GZipStream(originalFileStream, CompressionMode.Decompress))
                    {
                        await decompression.CopyToAsync(decompressed);
                    }
                }
            }

            Info.Delete();

            return newFileName;
        }
开发者ID:JustBytes,项目名称:JustBytes.Patcher,代码行数:27,代码来源:Helper.cs

示例8: Decompress

		/// <summary>
		/// takes byte array and decompress it into Content
		/// </summary>
		public async Task Decompress()
		{
			if (CompressedContent != null && CompressedContent.Length != 0)
			{
				using (MemoryStream inStream = new MemoryStream(CompressedContent))
				using (MemoryStream outStream = new MemoryStream())
				{
					using (GZipStream gz = new GZipStream(inStream, CompressionMode.Decompress))
					{
						await gz.CopyToAsync(outStream);
					}
					Content = Encoding.Unicode.GetString(outStream.ToArray());
				}
			}
			else
			{
				Content = "";
			}
		}
开发者ID:ILya-Lev,项目名称:TextEditor,代码行数:22,代码来源:TextFile.cs

示例9: SaveToFile

        /// <summary>
        /// Saves content of this attachment to a temp file.
        /// </summary>
        /// <returns></returns>
        public async Task<IStorageFile> SaveToFile()
        {
            var target = await ApplicationData.Current.TemporaryFolder
                .CreateFolderAsync("Attachments",
                    CreationCollisionOption.OpenIfExists);

            var file = await target.CreateFileAsync(Key,
                CreationCollisionOption.ReplaceExisting);

            var value = Value;
            var compressed = value.Attribute("Compressed");
            var isCompressed = compressed != null && (bool)compressed;


            if (!isCompressed)
            {
                var buffer = CryptographicBuffer
                    .DecodeFromBase64String(value.Value);
                await FileIO.WriteBufferAsync(file, buffer);
            }
            else
            {
                var bytes = Convert.FromBase64String(value.Value);

                using (var buffer = new MemoryStream(bytes))
                using (var gz = new GZipStream(buffer, CompressionMode.Decompress))
                using (var output = await file.OpenStreamForWriteAsync())
                {
                    await gz.CopyToAsync(output);
                }
            }

            return file;
        }
开发者ID:Confuset,项目名称:7Pass-Remake,代码行数:38,代码来源:EntryAttachmentViewModel.cs


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