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


C# GZipStream.Read方法代码示例

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


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

示例1: Decompress

            public static void Decompress(FileInfo archFile, out String szOutFile)
            {
                Logger.Enter();
                using (FileStream archFileStream = archFile.OpenRead())
                {
                    String currentFileName = archFile.FullName;
                    String newFileName = currentFileName.Remove(
                        currentFileName.Length - archFile.Extension.Length);

                    using (FileStream normalFileStream = File.Create(newFileName))
                    {
                        using (GZipStream decompressionStream = new GZipStream(archFileStream, CompressionMode.Decompress))
                        {
                            byte[] buffer = new byte[1024];
                            int nRead;
                            while ((nRead = decompressionStream.Read(buffer, 0, buffer.Length)) > 0)
                            {
                                normalFileStream.Write(buffer, 0, nRead);
                            }

                            szOutFile = newFileName;
                            Console.WriteLine("Decompressed: {0}", archFile.Name);
                        }
                    }
                }
                Logger.Leave();
            }
开发者ID:AndrianDTR,项目名称:Atlantic,代码行数:27,代码来源:Packer.cs

示例2: Assemble

    static void Assemble(string[] files, string destinationDirectory)
    {
        using (var assemly = new FileStream(destinationDirectory + GetFileName() + "-Assembled" + GetExtention(), FileMode.Create))
        {
            for (int i = 0; i < files.Length; i++)
            {
                using (var source = new FileStream(filePartsNames[i] + ".gz", FileMode.Open))
                {
                    using (var gz = new GZipStream(source, CompressionMode.Decompress))
                    {
                        byte[] buffer = new byte[4096];

                        while (true)
                        {
                            int readBytes = gz.Read(buffer, 0, buffer.Length);
                            if (readBytes == 0)
                            {
                                break;
                            }
                            assemly.Write(buffer, 0, buffer.Length);
                        }
                    }
                }
            }
        }
    }
开发者ID:TheTypoMaster,项目名称:Homework-And-Solved-Problems,代码行数:26,代码来源:Zipping+Sliced+Files.cs

示例3: Assemble

    private static void Assemble(List<string> file, string name, string destinationDir)
    {
        Directory.CreateDirectory(destinationDir);
        FileStream write = new FileStream(destinationDir + name, FileMode.Append);

        byte[] buffer = new byte[4096];
        using (write)
        {
            for (int i = 0; i < file.Count; i++)
            {
                using (FileStream reader = new FileStream("../dir/" + file[i], FileMode.Open))
                {
                    using (GZipStream gz = new GZipStream(reader, CompressionMode.Decompress, false))
                    {
                        while (true)
                        {
                            int bytes = gz.Read(buffer, 0, buffer.Length);
                            if (bytes == 0)
                            {
                                break;
                            }
                            write.Write(buffer, 0, bytes);
                        }
                    }
                }
            }
        }
    }
开发者ID:EBojilova,项目名称:SoftUni-3,代码行数:28,代码来源:Program.cs

示例4: Assemble

    static void Assemble(List<string> files, string destinationDirectory)
    {
        using (FileStream combined = new FileStream(destinationDirectory + "combined files" + extensionSource, FileMode.Create))
        {
            for (int file = 0; file < files.Count; file++)
            {
                using (FileStream input = new FileStream(files[file], FileMode.Open))
                {
                    using (GZipStream commpression = new GZipStream(input, CompressionMode.Decompress, false))
                    {
                        byte[] buffer = new byte[4096];

                        while (true)
                        {
                            int readBytes = commpression.Read(buffer, 0, buffer.Length);

                            if (readBytes == 0)
                            {
                                break;
                            }
                            combined.Write(buffer, 0, readBytes);
                        }
                    }
                }
            }
        }
    }
开发者ID:VTeneva,项目名称:Advanced-CSharp-HW,代码行数:27,代码来源:ZippingSlicedFiles.cs

示例5: Assemble

 private static void Assemble(List<string> files, string destinationDirectory)
 {
     var allData = new List<byte>();
         for (int i = 0; i < files.Count; i++)
         {
             var sourceFile = files[i];
             using (var source = new FileStream(sourceFile, FileMode.Open))
             {
                 using (var zip = new GZipStream(source, CompressionMode.Decompress))
                 {
                     byte[] buffer = new byte[4096];
                     while (true)
                     {
                         int readBytes = zip.Read(buffer, 0, buffer.Length);
                         if (readBytes == 0)
                         {
                             break;
                         }
                         for (int j = 0; j < readBytes; j++)
                         {
                             allData.Add(buffer[j]);
                         }
                     }
                 }
             }
         }
         using (var copy = new FileStream(destinationDirectory, FileMode.Create))
         {
             copy.Write(allData.ToArray(), 0, allData.Count);
         }
 }
开发者ID:PlamenaMiteva,项目名称:CSharp_Advanced,代码行数:31,代码来源:06.+Zipping+Sliced+Files.cs

示例6: Assemble

    private static void Assemble(int parts)
    {
        byte[] buffer = new byte[4096];
        for (int i = 1; i <= parts; i++)
        {
            string source = String.Format("../../{0}.gz", i);
            FileStream partOfFile = new FileStream(source, FileMode.Open);
            FileStream assembledFile = new FileStream("../../assembled.txt", FileMode.Append);

            using (partOfFile)
            {
                using (assembledFile)
                {
                    using (GZipStream decompression = new GZipStream(partOfFile, CompressionMode.Decompress))
                    {
                        while (true)
                        {
                            int bytesRead = decompression.Read(buffer, 0, buffer.Length);
                            if (bytesRead == 0)
                            {
                                break;
                            }
                            assembledFile.Write(buffer, 0, bytesRead);
                        }
                    }

                }
            }
        }
    }
开发者ID:petdakov,项目名称:SoftUni-Homeworks,代码行数:30,代码来源:GzipStream.cs

示例7: AssembleGZip

    private static void AssembleGZip(List<string> files, string destinationDirectory)
    {
        string[] dotItems = files[0].Split('.');
        string ext = dotItems[dotItems.Length - 2];

        string destinationFile = destinationDirectory + "assembled." + ext;
        using (FileStream dest = new FileStream(destinationFile, FileMode.Append, FileAccess.Write))
        {

            foreach (string inFile in files)
            {
                using (FileStream source = new FileStream(inFile, FileMode.Open))
                {
                    using (GZipStream sourceGZip = new GZipStream(source, CompressionMode.Decompress, false))
                    {
                        byte[] buffer = new byte[4096];
                        int len;
                        while ((len = sourceGZip.Read(buffer, 0, buffer.Length)) > 0)
                            dest.Write(buffer, 0, len);
                    }

                }
            }
        }
    }
开发者ID:IvoArsov,项目名称:Advanced-CSharp-Course,代码行数:25,代码来源:ZippingSlicedFiles.cs

示例8: Assemble

    static void Assemble(List<string> files, string destinationDirectory)
    {
        string fileOutputPath = destinationDirectory + "assembled" + "." + matches[0].Groups[3];
        var fsSource = new FileStream(fileOutputPath, FileMode.Create);
        fsSource.Close();

        using (fsSource = new FileStream(fileOutputPath, FileMode.Append))
        {
            // reading the file paths of the parts from the files list
            foreach (var filePart in files)
            {
                using (var partSource = new FileStream(filePart, FileMode.Open))
                {
                    using (var compressionStream = new GZipStream(partSource,CompressionMode.Decompress,false))
                    {
                        // copy the bytes from part to new assembled file
                        Byte[] bytePart = new byte[4096];
                        while (true)
                        {
                            int readBytes = compressionStream.Read(bytePart, 0, bytePart.Length);
                            if (readBytes == 0)
                            {
                                break;
                            }

                            fsSource.Write(bytePart, 0, readBytes);
                        }
                    }
                }
            }
        }
    }
开发者ID:sokito,项目名称:Softuni,代码行数:32,代码来源:ZipingSlicedFiles.cs

示例9: readStream

    public static MemoryStream readStream(FileStream stream)
    {
        MemoryStream outStream = new MemoryStream();

        GZipStream compress = new GZipStream(stream, CompressionMode.Decompress, false);

        byte[] buffer = new Byte[stream.Length];

        while (true)
        {
            int count = compress.Read(buffer, 0, buffer.Length);

            if (count != 0)
            {
                outStream.Write(buffer, 0, buffer.Length);
            }

            if (count != buffer.Length)
            {
                break;
            }
        }

        compress.Close();
        outStream.Close();
        stream.Close();

        return new MemoryStream(outStream.ToArray());
    }
开发者ID:Robbss,项目名称:TheGame,代码行数:29,代码来源:fileHandler.cs

示例10: Decompress

 public static byte[] Decompress(byte[] data)
 {
     MemoryStream input = new MemoryStream();
     input.Write(data, 0, data.Length);
     input.Position = 0;
     GZipStream gzip = new GZipStream(input,
                       CompressionMode.Decompress, true);
     MemoryStream output = new MemoryStream();
     byte[] buff = new byte[64];
     int read = -1;
     read = gzip.Read(buff, 0, buff.Length);
     while (read > 0)
     {
         output.Write(buff, 0, read);
         read = gzip.Read(buff, 0, buff.Length);
     }
     gzip.Close();
     return output.ToArray();
 }
开发者ID:SwarmCorp,项目名称:Swarmops,代码行数:19,代码来源:CompressedViewStatePageBase.cs

示例11: Decompress

    /// <summary>
    /// 
    /// </summary>
    /// <param name="data"></param>
    /// <returns></returns>
    public static byte[] Decompress(byte[] data)
    {
        using (var compressedStream = new MemoryStream(data))
        using (var zipStream = new GZipStream(compressedStream, CompressionMode.Decompress))
        using (var resultStream = new MemoryStream())
        {
            var buffer = new byte[4096];
            int read;

            while ((read = zipStream.Read(buffer, 0, buffer.Length)) > 0)
            {
                resultStream.Write(buffer, 0, read);
            }

            return resultStream.ToArray();
        }
    }
开发者ID:heyjohnnyc,项目名称:mikulus,代码行数:22,代码来源:ByteArrayUtilities.cs

示例12: Decompress

    public static byte[] Decompress(byte[] b)
    {
        MemoryStream ms = new MemoryStream(b.Length);
        ms.Write(b, 0, b.Length);

        // last 4 bytes of GZipStream = length of decompressed data
        ms.Seek(-4, SeekOrigin.Current);
        byte[] lb = new byte[4];
        ms.Read(lb, 0, 4);
        int len = BitConverter.ToInt32(lb, 0);
        ms.Seek(0, SeekOrigin.Begin);

        byte[] ob = new byte[len];
        GZipStream zs = new GZipStream(ms, CompressionMode.Decompress);
        zs.Read(ob, 0, len);

        return ob;
    }
开发者ID:spbooks,项目名称:ASPNETANT1,代码行数:18,代码来源:CompressedViewStatePage.cs

示例13: Assemble

 static void Assemble(List<string> files, string destinationDirectory)
 {
     byte[] buffer = new byte[4096];
     int readBytes;
     string fileExtension = Source.Substring(Source.Length - 4);
     using (FileStream writingStream = new FileStream(destinationDirectory + "\\assembled" + fileExtension, FileMode.Create))
     {
         foreach (var file in files)
         {
             using (FileStream readingStream = new FileStream(file, FileMode.Open))
             {
                 using (GZipStream decompressionStream = new GZipStream(readingStream, CompressionMode.Decompress, false))
                 {
                     while ((readBytes = decompressionStream.Read(buffer, 0, buffer.Length)) != 0)
                     {
                         writingStream.Write(buffer, 0, readBytes);
                     }
                 }
             }
         }
     }
 }
开发者ID:psdimitrov,项目名称:homeworks,代码行数:22,代码来源:ZippingSlicedFiles.cs

示例14: AssembleFiles

 private static void AssembleFiles(int i)
 {
     using (var source = new FileStream(string.Format("../../Part-{0}.txt", i), FileMode.Open))
     {
         using (var zip = new GZipStream(source, CompressionMode.Decompress))//DEKOMPRESIRA
         {
             using (var destination = new FileStream(assemblePath, i == 0 ? FileMode.Create : FileMode.Append))
             {
                 byte[] buffer = new byte[4096];
                 while (true)
                 {
                     int readBytes = zip.Read(buffer, 0, buffer.Length);//chetem ot kompresirania fail
                     if (readBytes == 0)
                     {
                         break;
                     }
                     destination.Write(buffer, 0, readBytes);//zapisva dekompresiranite baitove v destination
                 }
             }
         }
     }
 }
开发者ID:zhecho1215,项目名称:Softuni,代码行数:22,代码来源:ZippingSlicingFile.cs

示例15: AssembleFiles

 private static void AssembleFiles(int i)
 {
     using (var source = new FileStream(string.Format("../../Part-{0}.txt", i), FileMode.Open))
     {
         using (var zip = new GZipStream(source, CompressionMode.Decompress))
         {
             using (var destination = new FileStream(assemblePath, i == 0 ? FileMode.Create : FileMode.Append))
             {
                 byte[] buffer = new byte[4096];
                 while (true)
                 {
                     int readBytes = zip.Read(buffer, 0, buffer.Length);
                     if (readBytes == 0)
                     {
                         break;
                     }
                     destination.Write(buffer, 0, readBytes);
                 }
             }
         }
     }
 }
开发者ID:IlianStefanov,项目名称:SoftUni,代码行数:22,代码来源:ZippedSlicedFile.cs


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