我如何ZIP在C#中的文件,不使用第三方的API? [英] How do I ZIP a file in C#, using no 3rd-party APIs?

查看:153
本文介绍了我如何ZIP在C#中的文件,不使用第三方的API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是pretty肯定这是不是一个重复这样我承担只需一分钟。

I'm pretty sure this is not a duplicate so bear with me for just a minute.

我如何编程(C#)ZIP(在Windows)的文件,而无需使用任何第三方库?我需要一个本地的Windows电话或类似的东西;我真的不喜欢,启动过程的想法,但我会如果我绝对要。一个PInovke调用会好得多。

How can I programatically (C#) ZIP a file (in Windows) without using any third party libraries? I need a native windows call or something like that; I really dislike the idea of starting a process, but I will if I absolutely have to. A PInovke call would be much better.

如果做不到这一点,让我告诉你我真正想要完成:我需要让用户下载的文档集合在一个请求的能力。如何做到这一点任何想法?

Failing that, let me tell you what I'm really trying to accomplish: I need the ability to let a user download a collection of documents in a single request. Any ideas on how to accomplish this?

推荐答案

您使用.NET 3.5?你可以使用<$c$c>ZipPackage类和相关的类。它不是因为它想要一个MIME类型添加的每个文件压缩和解只是一个文件列表了。它可以做你想做的。

Are you using .NET 3.5? You could use the ZipPackage class and related classes. Its more than just zipping up a file list because it wants a MIME type for each file you add. It might do what you want.

我目前使用这些类类似的问题存档几个相关的文件到下载一个文件。我们使用文件扩展名来下载文件与我们的桌面应用程序关联。我们遇到了一个小问题是,它不可能只使用第三方工具,如7-ZIP创建的zip文件,因为客户端code不能打开它 - ZipPackage添加描述一个隐藏的文件每个组件文件的内容类型,如果该内容类型文件丢失无法打开zip文件。

I'm currently using these classes for a similar problem to archive several related files into a single file for download. We use a file extension to associate the download file with our desktop app. One small problem we ran into was that its not possible to just use a third-party tool like 7-zip to create the zip files because the client side code can't open it -- ZipPackage adds a hidden file describing the content type of each component file and cannot open a zip file if that content type file is missing.

这篇关于我如何ZIP在C#中的文件,不使用第三方的API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆