I have a VERY simple program using DotNetZip (most current version) with C#.Net, VS2010. It has begun hanging when it tries to save the file it has zipped up. No error messages, no nothing. It ran fine for a long time, then suddenly started showing this intermittent symptom. I run it using a batch system on MS Server 2003, but I test it on Win7. Both systems yield the intermittent failure. Fails about 80% of the time.
Ideas?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ionic.Zip;
namespace ZipUpSourceFiles
{
class Program
{
static void Main(string[] args)
{
string YYYYMMM = DateTime.Today.ToString("yyyy-MMM");
string TargetPath = @"\\winntdom\root\common\xxx\secure\Construction\Access\All Database Backup\" + YYYYMMM + @"_Backup\";
string SourcePath = @"\\winntdom\root\common\xxx\secure\Construction\Access\YYYY\";
string ZipName=DateTime.Today.ToString("yy-MM-dd") + @".zip";
string ZipWithPath = TargetPath + ZipName;
if (!System.IO.Directory.Exists(TargetPath))
{
Console.WriteLine("Creating Directory");
System.IO.Directory.CreateDirectory(TargetPath);
}
if (System.IO.File.Exists(ZipWithPath))
{
Console.WriteLine("Deleting file");
System.IO.File.Delete(ZipWithPath);
}
using (ZipFile zip = new ZipFile())
{
Console.WriteLine("Zipping up Directories");
zip.AddDirectory(SourcePath); // recurses subdirectories
Console.WriteLine("Saving Directories {0}",ZipName);
zip.Save(ZipWithPath);
Console.WriteLine("Finishing Up");
}
}
}
}
After some further googling, I found a reference that suggesting increasing buffer size properties. I did that, and it's working.
zip.BufferSize = 1000000;
zip.CodecBufferSize = 1000000;