Hi. I'm trying to compress a folder (and it's subdirectories). I've adapted code I've found on the net which zip's up the files within the folder specified, but not the sub-folders (ie, the entire contents).
Here's the code:
string filenames = Directory.GetFiles(str_vledatasource.Text);
using (ZipOutputStream s = new ZipOutputStream(File.Create(str_vledatadestination.Text+"\\VLE Backup ("+ strTimeStamp.ToString()+").zip")))
s.SetLevel(9); // 0-9, 9 being the highest compression
byte buffer = new byte;
foreach (string file in filenames)
ZipEntry entry = new
entry.DateTime = DateTime.Now;
using (FileStream fs = File.OpenRead(file))
sourceBytes = fs.Read(buffer, 0, buffer.Length);
s.Write(buffer, 0, sourceBytes);
while (sourceBytes > 0);
Can anyone help me finish this off, please?
str_vledatasource.Text is the string for the location
str_vledatadestination.Text is the string for the output/destination of the zip.