走马谷歌搜索没有返回任何足够简单理解(我是pretty的新的函数式编程)。
Cursory Google search didn't return anything simple enough to understand (i'm pretty new to functional programming).
如果我有文件的数组,我怎么能压缩每个文件,然后创建的所有压缩文件的zip?
if I have an array of files, how can i zip each file and then create a zip of all zipped files?
我有这样的事情至今:
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?
编辑:这是我迄今为止,但我发现了一些奇怪的行为。更多的惊喜,一旦我弄清楚什么奇怪的行为是完全相同:
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")
更新:我不认为怪异行为是关系到ZIP模块。我AP preciate所有帮助!
UPDATE: I don't think the "strange behavior" is related to the zip module. I appreciate all the help!
您想要创建一个独立执行程序的zip COM pression?
Are you trying to create an independent implementation of zip compression?
我会用DotNetZip从 HTTP://dotnetzip.$c$cplex.com/ - 这是一个单一的,有管理的code(C#)组件。从F#中使用它应该是pretty的多简单,只要在工程中引用的程序集。
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.
用法很简单。对于C#:
Usage is simple. For C#:
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");
}
如果您要压缩的压缩文件的集合(为什么?),还有一些方法可以做到这一点与DotNetZip(你可以,例如,你的ZIP文件保存到流,或添加一个流一个zip文件)。
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).
希望这有助于!