public string Unzip(string sourcepath)
{
FileStream inputfile = File.OpenRead(sourcepath);
DeflateStream deflatestream = new DeflateStream(inputfile, CompressionMode.Decompress);
byte[] buffer = new byte[inputfile.Length + 100];
int offset = 0;
int ct = 0;
while (true)
{
int bytesread = deflatestream.Read(buffer, offset, 100);
if(bytesread == 0)
{
break;
}
offset += bytesread;
ct += bytesread;
}
FileStream outputfile = File.Create(Path.ChangeExtension(sourcepath, "xml"));
outputfile.Write(buffer, 0, buffer.Length);
outputfile.Close();
return "Done";
}
|