Click here to Skip to main content
15,891,136 members
Home / Discussions / C#
   

C#

 
AnswerRe: DataGridView - Add any controls to a cell Pin
wheelerbarry18-Sep-06 2:38
wheelerbarry18-Sep-06 2:38 
QuestionHow to hide drives under My Computer tree in OpenFileDialog box using C# Pin
kumar.bs18-Sep-06 2:07
kumar.bs18-Sep-06 2:07 
QuestionProblem with slow screen update Pin
BerntR18-Sep-06 1:57
BerntR18-Sep-06 1:57 
AnswerRe: Problem with slow screen update Pin
g00fyman18-Sep-06 2:05
g00fyman18-Sep-06 2:05 
GeneralRe: Problem with slow screen update Pin
BerntR18-Sep-06 2:22
BerntR18-Sep-06 2:22 
GeneralRe: Problem with slow screen update Pin
g00fyman18-Sep-06 2:26
g00fyman18-Sep-06 2:26 
GeneralRe: Problem with slow screen update Pin
BerntR18-Sep-06 6:10
BerntR18-Sep-06 6:10 
QuestionThe magic number in GZip header is not correct.(decompressing a .zip file) Pin
jimmyfingers18-Sep-06 1:36
jimmyfingers18-Sep-06 1:36 
I've just tried the following code for decompressing a .zip file, but get the following error message:
"The magic number in GZip header is not correct. Make sure you are passing in a GZip stream."
The error is on line 27: "int bytesRead = compressedZipStream.Read(smallBuffer, 0, 100);"

My code is as follows:

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.IO.Compression;


namespace GZipText_decompression
{
class decompressionTest
{
static void Main(string[] args)
{
FileStream inputFile= null;
GZipStream compressedZipStream = null;

try
{
//determine the uncompressed size of the file
inputFile = new FileStream("c:\\translated_catalog.zip", FileMode.Open, FileAccess.Read, FileShare.Read);
compressedZipStream = new GZipStream(inputFile, CompressionMode.Decompress);
int offSet = 0;
int totalBytes = 0;
byte[] smallBuffer = new byte[100];
while (true)
{
int bytesRead = compressedZipStream.Read(smallBuffer, 0, 100);
if (bytesRead == 0)
{
break;
}
offSet += bytesRead;
totalBytes += bytesRead;
}
compressedZipStream.Close();

//open and read contents of the file no that the uncompressed size is known
inputFile = new FileStream("c:\\translated_catalog.zip", FileMode.Open, FileAccess.Read, FileShare.Read);

//Decompress the file contents
compressedZipStream = new GZipStream(inputFile, CompressionMode.Decompress);

byte[] buffer = new byte[totalBytes];
compressedZipStream.Read(buffer, 0, totalBytes);

//Display decompression information
Console.WriteLine(Encoding.UTF7.GetString(buffer));
Console.WriteLine("Compressed size is {0} and decompressed size is {1} ", inputFile.Length, buffer.Length);
compressedZipStream.Close();
Console.ReadLine();


}
finally
{
if (inputFile != null)
{
inputFile.Close();
}
if (compressedZipStream != null)
{
compressedZipStream.Close();
}
}
}
}
}

The file that I'm decompressing is a .zip file.
Any ideas?
QuestionRun setup or software ?? Pin
MHASSANF18-Sep-06 1:28
MHASSANF18-Sep-06 1:28 
AnswerRe: Run setup or software ?? Pin
g00fyman18-Sep-06 2:00
g00fyman18-Sep-06 2:00 
GeneralRe: Run setup or software ?? Pin
MHASSANF18-Sep-06 2:39
MHASSANF18-Sep-06 2:39 
QuestionAn application for windows (.net/c#) from which i can copy values to open office documents? Pin
indiaone18-Sep-06 1:20
indiaone18-Sep-06 1:20 
Questionwizard Pin
Parshant Verma18-Sep-06 1:08
Parshant Verma18-Sep-06 1:08 
AnswerRe: wizard Pin
g00fyman18-Sep-06 2:11
g00fyman18-Sep-06 2:11 
QuestionCondition checking in Setup creation Pin
karthiBalu18-Sep-06 1:05
karthiBalu18-Sep-06 1:05 
QuestionXML serialization with GZip Pin
Scarsymmetry18-Sep-06 0:33
Scarsymmetry18-Sep-06 0:33 
Questionwriting a utility file Pin
saqib8218-Sep-06 0:19
saqib8218-Sep-06 0:19 
AnswerRe: writing a utility file Pin
User 665818-Sep-06 1:03
User 665818-Sep-06 1:03 
GeneralRe: writing a utility file Pin
saqib8218-Sep-06 1:42
saqib8218-Sep-06 1:42 
GeneralRe: writing a utility file Pin
g00fyman18-Sep-06 2:08
g00fyman18-Sep-06 2:08 
QuestionImage downloading Pin
AnnnS18-Sep-06 0:17
AnnnS18-Sep-06 0:17 
AnswerRe: Image downloading Pin
Hamid_RT18-Sep-06 9:33
Hamid_RT18-Sep-06 9:33 
QuestionIn OpenFileDialog windows under "My computer" Drives are not getting displayed Pin
kumar.bs18-Sep-06 0:16
kumar.bs18-Sep-06 0:16 
QuestionProblem in Creating Lines (/n) Pin
praveenqwe18-Sep-06 0:07
praveenqwe18-Sep-06 0:07 
AnswerRe: Problem in Creating Lines (/n) Pin
albCode18-Sep-06 0:08
albCode18-Sep-06 0:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.