Creating Zip Files
Well I have gone through this before but having just gone throug this again I figured I'd blog it so I wont forget the next time. I have been creating a zip of former log files so I don't loose them, i.e. app starts and runs and writes to a log. The next startup takes the existing log and adds it to a zip file then creates a new one so I have the old log (compressed) and a new log. OK, enough of that. To make the above process work;
If the log file exists
open a byte array stream to copy to
open a zip output stream using the byte array as the back end
copy the entries from the old file to the buffer
open a ZipFile on the .zip file
get the enumeration for the entries and iterate
get the input stream for the entry
add an entry to the new zip stream
read the input stream and write it to the zip stream
close the entry
add the existing log file to the buffer
add the entry
write the file to the zip output stream
close the zip output stream
write the buffer to the existing zip file (i.e. override)
I could put code but its too much with all the exception handling etc.

