Software Development Uncategorized

ZipArchives in .NET 4.5

I've been playing with the new (better? improved?) support for zip files in .NET 4.5 and ran into some issues recently where I couldn't read the contents of an archive I had created or when I added entries to an archive, they never appeared.

When I would create the archive using the ZipFile.CreateFromDirectory() method, everything worked just fine:

ZipArchive archive = ZipFile.CreateFromDirectory("C:\\PathToSomeDirectorySomewhere",

However, when I tried to add files to it, they would never show up:

ZipArchiveEntry entry = archive.CreateEntryFromFile("PathToSomeOtherNewFile",

So I decided to try creating the zip file manually, thinking that maybe there was an issue with modifying a CreateFromDirectory() archive:

ZipArchive archive = ZipFile.Open("C:\",

Now, when I opened it with WinRAR (or 7Zip, or <insert tool of choice>), I received some errors when trying to actually view the contents of entries.

At this point, I'm thinking that I'm missing something that actually closes the file or writes it to disk; it turns out that I was. I added archive.Dispose() to the end of the file and everything started working. Lazy programmer me. After re-reading the example I had been using (from this MSDN Magazine article:, I realized that I had missed a critical difference between the example and my implementation:

using (ZipArchive archive = ZipFile.Open(...)
   //Stuff goes here...

This pretty much took care of the issue entirely - just make sure that the ZipArchive is disposed when you're done with it.

Random.Next(); Religion Uncategorized

Two Archbishops at Odds

I really hate to see bishops disagree; but in this case, I firmly stand behind Archbishop Coakley!


On Chant in the Mass

Great video featuring interviews with several of the best minds in the Catholic Church regarding the use of (traditional) Latin chants in the liturgy:


News Uncategorized

Life is Precious

Hug your children tonight; remember how incredibly precious of a gift each of them is. Don't let them go to bed with letting each of them know how much you love them and how much joy they bring into your life.