Quantcast
Channel: SharpDevelop Community
Viewing all articles
Browse latest Browse all 1764

Cannot access a disposed object: ZipFile

$
0
0

I'm getting this error intermittently when trying to do a normal, vanilla zip of a bunch of files (about 65 files - 45MB). This is Windows 7 and the current release of ICSharpCode.SharpZipLib. I'm sorry I don't have a stack dump - the process runs "detached" from the system tray (no user interface), so when it crashes the only thing I do is write the exception's message to the Windows event log. But I can at least provide you with the relevant piece of code:

 

 

            string[ files = Directory.GetFiles(infolder);

            using (ZipFile zip = ZipFile.Create(tempfile))

            {

                zip.BeginUpdate();

                foreach (string file in files)

                {

                    string name = Path.GetFileName(file);

                    if (name == "EXPORT.TXT" || name == "persist.xml")

                    {

                        zip.Add(file, name);

                        continue;

                    }

                    if (Path.GetExtension(name) != ".TIF")

                        continue;

                    try

                    {

                        // be sure it's a .tif that we want

                        val.Validate(Path.GetFileNameWithoutExtension(name));

                    }

                    catch (ArgumentException)

                    {

                        continue;

                    }

                    zip.Add(file, name);

                }

                zip.CommitUpdate();

                zip.Close();

            }

I believe the exception is occurring on the CommitUpdate call (I have an outer try/catch as a last-chance exception handler which is where I write to the event log). Can you please tell me what I'm doing wrong, or at least suggest a way where I might be able to consistently reproduce the problem? Thanks!

Viewing all articles
Browse latest Browse all 1764

Trending Articles