Sauberes Zip – File – Handling mit .NET
Eben hab ich bei Norbert im Blog gelesen, dass Microsoft auf Codeplex eine Library zum manipulieren von Zip – Dateien eingestellt hat.
Features:
DotNetZip works on PCs with the full .NET Framework, and also runs on mobile devices that use the .NET Compact Framework. Create and read zip files in VB, C#, or any .NET language, or any scripting environment. DotNetZip supports these scenarios:
- an ASP.NET app that dynamically creates ZIP files and allows a browser to download them
- a Windows Service that periodically zips up a directory for backup and archival purposes
- a WPF program that modifyies an existing archive – renaming entries, removing entries from an archive, or adding new entries to an archive
- a Windows Forms app that creates AES-encrypted zip archives for privacy of archived content.
- An administrative script in PowerShell or VBScript that performs backup and archival.
- a WCF service that receives a zip file as an attachment, and dynamically unpacks the zip to a stream for analysis
- creating zip files from stream content, saving to a stream, extracting to a stream, reading from a stream
- creation of self-extracting archives.
C# – Codebeispiel
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | try { using (ZipFile zip = new ZipFile()) { // add this map file into the "images" directory in the zip archive zip.AddFile("c:\\images\\personal\\7440-N49th.png", "images"); // add the report into a different directory in the archive zip.AddFile("c:\\Reports\\2008-Regional-Sales-Report.pdf", "files"); zip.AddFile("ReadMe.txt"); zip.Save("MyZipFile.zip"); } } catch (System.Exception ex1) { System.Console.Error.WriteLine("exception: " + ex1); } |
Weitere Infos gibts bei Norbert oder Codeplex
Mai 27, 2009 | Kategorie Programmierung | Kommentieren