Chris said:
Thhats the same lib I downloaded but I can't seem to unzip a .zip
file. Do you have any ideas?
Well, using ZipFile, ZipInputStream and ZipEntry seem to be a good bet
to me.
I've just written this code which unzips a file - but it doesn't do
anything about paths etc, so will fail on various zip files. It just
demonstrates the very basic ideas.
using System.IO;
using ICSharpCode.SharpZipLib.Zip;
public class Test
{
static void Main(string[] args)
{
foreach (string x in args)
{
Unzip (x);
}
}
static void Unzip (string zipName)
{
byte[] buffer = new byte[16384];
ZipFile zipFile = new ZipFile(zipName);
try
{
foreach (ZipEntry entry in zipFile)
{
Stream input = zipFile.GetInputStream(entry);
using (Stream output = File.Create(entry.Name))
{
int read;
while((read=input.Read(buffer,0,buffer.Length))>0)
{
output.Write(buffer, 0, read);
}
}
}
}
finally
{
zipFile.Close();
}
}
}