Blue Theme Orange Theme Green Theme Red Theme
 
Nevron Gauge for SharePoint
Home | Forums | ASP.NET 2.0 Tutorials | Web Services | How Do I...? | Class Browser | WPF Quick Starts | Advertise with Us
 | Consulting  
Submit an Article Submit a Blog 
Search :       Advanced Search »
Home » Blogs Home » Blog Detail

CopyTo in GZipStream Class

 by Ankur Gupta on May 03, 2011

In VS2010 we found a new function CopyTo in GZipStream Class.
Comments: 1 Views: 1547 Printable Version 

In VS2010 we found a new function CopyTo in GZipStream Class.

By the help of this function we can unzip a large size of zip file without use of any ByteBuffer array.

In the previous version of Visual Studio we used either a third party dll of byte buffer array to Unzip any file but buffer has some own limitation so if the file size is very large i.e in GB then it threw and overflow exception.

But now in visual studio 2010 by the use of GZipStream Class and CopyTo method we can Unzip any size of file.

 in the following function in fi parameter you need to pass your own file information.

private void Decompress(FileInfo fi, string unZipedFilesPath)

        {

            try

            {

                // Get the stream of the source file.

                using (FileStream inFile = fi.OpenRead())

                {

                    // Get orignial file extension, for example "doc" from report.doc.gz.

                    string curFile = fi.Name;

                    dynamic origName = curFile.Remove(curFile.Length - fi.Extension.Length);

 

                    // Create the decompressed file.

                    Directory.CreateDirectory(unZipedFilesPath + "\\" + origName);

                    using (FileStream outFile = File.Create(unZipedFilesPath + "\\" + origName + "\\" + origName))

                    {

                        using (GZipStream Decompress = new GZipStream(inFile, CompressionMode.Decompress))

                        {

 

                            // Copy the decompression stream

                            // into the output file.

                            Decompress.CopyTo(outFile);

 

                            // Console.WriteLine("Decompressed: {0}", fi.Name);

 

                        }

                    }

                }

            }

            catch (Exception ex)

            {

            }

        }

 

Comment Request!
Thank you for reading this post. Please post your feedback, question, or comments about this post Here.
 
What do you say about this post? Post a comment here
*Title:
*Comment:
 

good info by Hirendra Sisodiya On May 03, 2011
good information

Nevron Gauge for SharePoint
Become a Sponsor

 Blogger's Profile
Age: 29
Location:
Title: Project Manager
Joined: May 15, 2010
Education: Masters Degree
 More Blogs from this Blogger
No record available
 Latest Blogs
[Video] OnClose Handler
[Video] Storing and Loading the Window and Toolbar position
The Euclidean Algorithm
Swapping Exe Process
How Exe file is Generated by VS2005 C++ Project?
What is Exe
Header files: Multiple Inclusion problem - Solution B
Header files: Multiple Inclusion problem - Solution A
Header files: Multiple Inclusion problem - Reason
Header files: Multiple Inclusion problem
View all »
 Latest Jobs
More ... 
 Latest Interview Questions
More ... 

 © 2012  contents copyright of their authors. Rest everything copyright Mindcracker. All rights reserved.