Sunday, September 20, 2015

.NET ZipFile.ExtractToDirectory Won't Merge With Existing Directories

I'm currently working on a program that deals with ZIP files, and since I'd rather not have to ship a third-party library if I can help it, I'm using .NET 4.5's System.IO.Compression features to manage ZIPs. The only downside that I've found so far is that the ZipFile.ExtractToDirectory method, which takes a ZIP file and unpacks it into the provided directory, refuses to do its work if the provided directory path already exists and has files or folders in it.

That's really inconvenient, because I'd like these ZIPs to merge with my existing file/folder structure. I would extract it to a separate directory and then move that directory onto the existing one, but Directory.Move won't overwrite/merge either. I did find a solution on Stack Overflow (using LINQ's GroupBy), though, so my program is working and I am happy.

No comments:

Post a Comment