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


C# GZipStream.CopyTo方法代码示例

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


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

示例1: Decompress

    public static byte[] Decompress(this Byte[] bytes)
    {
        using (MemoryStream tempMs = new MemoryStream()) {
            using (MemoryStream ms = new MemoryStream(bytes)) {
                GZipStream Decompress = new GZipStream(ms, CompressionMode.Decompress);
                Decompress.CopyTo(tempMs);
                Decompress.Close();

                return tempMs.ToArray();
            }
        }
    }
开发者ID:EaseEasy,项目名称:Ticket,代码行数:12,代码来源:CompressExtensions.cs

示例2: MutateIncoming

 public void MutateIncoming(TransportMessage transportMessage)
 {
     if (!transportMessage.Headers.ContainsKey("IWasCompressed"))
     {
         return;
     }
     using (GZipStream bigStream = new GZipStream(new MemoryStream(transportMessage.Body), CompressionMode.Decompress))
     {
         MemoryStream bigStreamOut = new MemoryStream();
         bigStream.CopyTo(bigStreamOut);
         transportMessage.Body = bigStreamOut.ToArray();
     }
 }
开发者ID:ryanrdl,项目名称:docs.particular.net,代码行数:13,代码来源:TransportMessageCompressionMutator.cs

示例3: MutateIncoming

 public Task MutateIncoming(MutateIncomingTransportMessageContext context)
 {
     if (!context.Headers.ContainsKey("IWasCompressed"))
     {
         return Task.FromResult(0);
     }
     using (GZipStream bigStream = new GZipStream(new MemoryStream(context.Body), CompressionMode.Decompress))
     {
         MemoryStream bigStreamOut = new MemoryStream();
         bigStream.CopyTo(bigStreamOut);
         context.Body = bigStreamOut.ToArray();
     }
     return Task.FromResult(0);
 }
开发者ID:eclaus,项目名称:docs.particular.net,代码行数:14,代码来源:TransportMessageCompressionMutator.cs

示例4: ExtractGZip

    /// <summary>
    ///     A FileInfo extension method that extracts the g zip.
    /// </summary>
    /// <param name="this">The @this to act on.</param>
    /// <example>
    ///     <code>
    ///           using System;
    ///           using System.IO;
    ///           using Microsoft.VisualStudio.TestTools.UnitTesting;
    ///           using Z.ExtensionMethods;
    ///           
    ///           namespace ExtensionMethods.Examples
    ///           {
    ///               [TestClass]
    ///               public class System_IO_FileInfo_ExtractGZip
    ///               {
    ///                   [TestMethod]
    ///                   public void ExtractGZip()
    ///                   {
    ///                       // Type
    ///                       var @this = new FileInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, &quot;Examples_System_IO_FileInfo_ExtractGZip.txt&quot;));
    ///                       var output = new FileInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, &quot;Examples_System_IO_FileInfo_ExtractGZip.gz&quot;));
    ///                       var outputExtract = new FileInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, &quot;Examples_System_IO_FileInfo_ExtractGZip_Example.txt&quot;));
    ///           
    ///                       // Intialization
    ///                       using (FileStream stream = @this.Create())
    ///                       {
    ///                       }
    ///           
    ///                       // Examples
    ///                       @this.CreateGZip(output);
    ///                      output.ExtractGZip(outputExtract);
    ///           
    ///                       // Unit Test
    ///                      Assert.IsTrue(outputExtract.Exists);
    ///                   }
    ///               }
    ///           }
    ///     </code>
    /// </example>
    public static void ExtractGZip(this FileInfo @this)
    {
        using (FileStream originalFileStream = @this.OpenRead())
        {
            string newFileName = Path.GetFileNameWithoutExtension(@this.FullName);

            using (FileStream decompressedFileStream = File.Create(newFileName))
            {
                using (var decompressionStream = new GZipStream(originalFileStream, CompressionMode.Decompress))
                {
                    decompressionStream.CopyTo(decompressedFileStream);
                }
            }
        }
    }
开发者ID:Nucs,项目名称:nlib,代码行数:55,代码来源:FileInfo.ExtractGZip.cs

示例5: DecompressFile

 public static bool DecompressFile(string pathToCompressedFile, string pathToDecompressedFile)
 {
     if (File.Exists(pathToCompressedFile))
     {
         using (FileStream inFile = File.Open(pathToCompressedFile, FileMode.Open))
         {
             using (FileStream outFile = File.Create(pathToDecompressedFile))
             {
                 using (GZipStream Decompress = new GZipStream(inFile,
                         CompressionMode.Decompress))
                 {
                     Decompress.CopyTo(outFile);
                 }
             }
         }
     }
     else
     {
         return false;
     }
     return true;
 }
开发者ID:Armoken,项目名称:Learning,代码行数:22,代码来源:Serializer.cs

示例6: GiaiNen

 //
 // Giai nen file TUDIEN duoc nen o dang .gz
 //
 public void GiaiNen(string DAUVAO, string DAURA)
 {
     using (FileStream streamMoFileGiaiNen = new FileStream(DAUVAO, FileMode.Open))
     {
         using (FileStream streamSauKhiGiaiNen = File.Create(DAURA))
         {
             using (GZipStream gzreader = new GZipStream(streamMoFileGiaiNen, CompressionMode.Decompress))
             {
                 gzreader.CopyTo(streamSauKhiGiaiNen);
             }
         }
     }
 }
开发者ID:nghiaht,项目名称:tudien-MO,代码行数:16,代码来源:Indexer.cs

示例7: ServiceRpc

        /// <summary>
        /// "transfer-encoding:chunked is not supported. 
        /// Workaround: Set 'git config --add --global http.postBuffer 10485760'
        /// </summary>
        /// <param name="serviceName"></param>
        private void ServiceRpc(string serviceName)
        {
            context.Response.ContentType = string.Format("application/x-git-{0}-result", serviceName);

            var fin = Path.GetTempFileName();
            var fout = Path.GetTempFileName();

            using (var file = File.Create(fin))
            {
                var encoding = context.Request.Headers["Content-Encoding"];
                if (string.IsNullOrEmpty(encoding))
                    encoding = context.Request.ContentEncoding.EncodingName;

                if (encoding.Equals("gzip"))
                {
                    using (GZipStream decomp = new GZipStream(context.Request.InputStream, CompressionMode.Decompress))
                    {
                        decomp.CopyTo(file);
                    }
                }
                else
                {
                    context.Request.InputStream.CopyTo(file);
                }
            }

            Git.RunGitCmd(string.Format("{0} --stateless-rpc \"{1}\" < \"{2}\" > \"{3}\"", serviceName, gitWorkingDir, fin, fout));
            context.Response.WriteFile(fout);
            context.Response.End();
            File.Delete(fin);
            File.Delete(fout);
        }
开发者ID:toshic,项目名称:Git-Web-Access,代码行数:37,代码来源:GitHandler.cs

示例8: DownloadSub

    protected void DownloadSub(object sender, EventArgs e)
    {
        var tempdir = Environment.GetEnvironmentVariable ("TEMP", EnvironmentVariableTarget.Machine);
        if (string.IsNullOrEmpty (tempdir))
            tempdir = "/tmp";

        var selectednode = (MovieTreeNode)MovieNodeView.NodeSelection.SelectedNode;
        if (selectednode == null)
            return;
        string movietitle = System.IO.Path.GetFileNameWithoutExtension (_fname);
        var client = new WebClient ();
        string filename = tempdir + "/tmp_" + movietitle + ".gz";
        client.DownloadFile (selectednode.DownloadLink, filename);
        var fileToDecompress = new FileInfo (filename);
        string currentFileName = fileToDecompress.FullName;
        string newFileName = currentFileName.Remove (currentFileName.Length - fileToDecompress.Extension.Length);

        using (FileStream originalFileStream = fileToDecompress.OpenRead()) {
            using (FileStream decompressedFileStream = File.Create(newFileName)) {
                using (var decompressionStream = new GZipStream(originalFileStream, CompressionMode.Decompress)) {
                    decompressionStream.CopyTo (decompressedFileStream);
                }
            }
        }
        fileToDecompress.Delete ();
        string origlocation = System.IO.Path.GetDirectoryName (_fname);
        string newfile = origlocation + "/" + movietitle + "." + selectednode.SubFormat;
        if (File.Exists (newfile)) {
            File.Delete (newfile);
        } //TODO: ask for overwrite?

        File.Move (newFileName, newfile);
        statusbar1.Push (3, "Downloaded " + newfile + ".");
        Downloadbutton.Sensitive = false;
    }
开发者ID:Koed00,项目名称:Subby,代码行数:35,代码来源:MainWindow.cs


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