Cursory Google search didn’t return anything simple enough to understand (i’m pretty new to functional programming).
if I have an array of files, how can i zip each file and then create a zip of all zipped files?
I have something like this so far:
let zip f =
f.zip //this is where I need the most direction
let zipAllAttachments f =
f
|> Seq.map zip //do I need to create another function to create a single zip of all zips?
EDIT: this is what I have so far, but I’m getting some strange behavior. More to come once I figure out what the strange behavior IS exactly:
use zipfile = new ZipFile()
for fileObj in files do
zipfile.AddFile(sprintf "%s%s" path fileObj.Filename) |> ignore
zipfile.Save("C:\\temp\\Compliance.zip")
UPDATE: I don’t think the “strange behavior” is related to the zip module. I appreciate all the help!
Are you trying to create an independent implementation of zip compression?
I’d use DotNetZip from http://dotnetzip.codeplex.com/ — it’s a single, managed code (C#) assembly. Using it from F# should be pretty much as simple as referencing the assembly from your project.
Usage is simple. For C#:
If you want to zip a collection of zip files (why?), there’s a number of ways to do that with DotNetZip (you can, for instance, save your zip file to a stream, or add a stream to a zip file).
Hope this helps!
Edited To Note: DotNetZip used to live at Codeplex. Codeplex has been shut down. The old archive is still [available at Codeplex][1]. It looks like the code has migrated to Github: