how to uncompress zip file into a text extension
<blockquote>
  <p><strong>Possible Duplicates:</strong><br>
  <a href="http://stackoverflow.com/questions/6241986/how-to-read-a-file">how to read a *.file</a><br>
  <a href="http://stackoverflow.com/questions/6241188/how-to-compress-and-uncompress-a-text-file">how to compress and uncompress a text file</a>  </p>
</blockquote>



<p>Hi,</p>

<p>I am having a problem in uncompressing the zip file into a text file, </p>

<p>when i compress the text file into a zip file (Ex-20110530.txt to 20110530.zip) .my code is compressing the code i use for compressing the text file to a zip file is </p>

<pre><code>       string path = (string)(Application.StartupPath + "\\TEMP\\TEMP_BACKFILL_atoz" + "\\" + name_atoz);
       StreamWriter Strwriter = new StreamWriter(path);
       DirectoryInfo di = new DirectoryInfo(path);
       FileInfo fi = new FileInfo(path);
       Compress(fi);

public static void Compress(FileInfo fi) 
{ 
    // Get the stream of the source file. 
    using (FileStream inFile = fi.OpenRead()) 
    {

        // Prevent compressing hidden and already compressed files. 
        if ((File.GetAttributes(fi.FullName) &amp; FileAttributes.Hidden) 
                != FileAttributes.Hidden &amp; fi.Name != ".zip") 
        { 
            // Create the compressed file. 
           using (FileStream outFile = File.Create(System.Text.RegularExpressions.Regex.Replace(fi.FullName, ".txt$", "") + ".zip"))

            { 
                using (GZipStream Compress = new GZipStream(outFile, 
                        CompressionMode.Compress)) 
                { 
                    // Copy the source file into the compression stream. 
                    byte[] buffer = new byte[4096]; 
                    int numRead; 
                    while ((numRead = inFile.Read(buffer, 0, buffer.Length)) != 0) 
                    { 
                        Compress.Write(buffer, 0, numRead); 
                    } 
                    Console.WriteLine("Compressed {0} from {1} to {2} bytes.", 
                        fi.Name, fi.Length.ToString(), outFile.Length.ToString()); 
                } 
            } 
        } 
    } 
} 
</code></pre>

<p>this code creates a zip file when i unzip the file it creates a file called 20110530 not a 20110530.txt . </p>

<p>I want the file to be uncompress with 20110530.txt format</p>

<p>the code i use to uncompress the file is</p>

<pre><code>    public static void Decompress(FileInfo fi)
    {
        // Get the stream of the source file. 
        using (FileStream inFile = fi.OpenRead())
        {
            // Get original file extension, for example "doc" from report.doc.gz. 
            string curFile = fi.FullName;
            string origName = curFile.Remove(curFile.Length - fi.Extension.Length);

            //Create the decompressed file. 
            using (FileStream outFile = File.Create(origName))
            {
                using (GZipStream Decompress = new GZipStream(inFile,
                        CompressionMode.Decompress))
                {
                    //Copy the decompression stream into the output file. 
                    byte[] buffer = new byte[4096];
                    int numRead;
                    while ((numRead = Decompress.Read(buffer, 0, buffer.Length)) != 0)
                    {
                        outFile.Write(buffer, 0, numRead);
                    }
                    Console.WriteLine("Decompressed: {0}", fi.Name);

                }
            }
        }
    } 
</code></pre>

<p>Can Anyone Pls Help Me,</p>

<p>Thanks In Advance.</p>
