0

I am trying to create an archive file and keep adding files to it until it is the next day. So like a rolling archive file per each day. I cant seem to figure this out, I can seem to create archive files for each file coming in, but not one giant one. Files are getting added every minute so we need a daily back up. Is it possible to keep adding entries and not save until the end of the day or is there a better way?

using(ZipFile zip = new ZipFile())
{
  zip.AddEntry(xmlName, xmlstring);
  zip.Save(Path.Combine(archivePath, zipFileName));
}

So now I have this but its still not quite right. It overwrites the existing file in the archive instead of adding to the file. I want it to write one file zipped

if (!File.Exists(archivePath))
{
    using (ZipFile zip = new ZipFile())
    {
        zip.AddEntry(xmlName, xmlString);
        zip.Save(Path.Combine(archivePath, zipFileName));
        log.DebugFormat("Archiving file {0} to {1}", zipFileName, to);
    }
}
else
{
    using (ZipFile zipFile = ZipFile.Read(archivePath))
    {
        zipFile.AddEntry(xmlName, xmlString);
        zipFile.Save(Path.Combine(archivePath, zipFileName));
        log.DebugFormat("Archiving file {0} to {1}", zipFileName, to);
    }
}
jomsk1e
  • 3,585
  • 7
  • 34
  • 59

0 Answers0