Mon, 03 Apr 2006 10:26
Zip Library
---------------------------------
The Microsoft .NET Framework {v2.0 v3.0 v3.5} includes new base class
libraries supporting compression within streams - both the
Deflate and Gzip formats are supported. But the new-for-.NET2.0
System.IO.Compression namespace provides streaming compression
only - useful for communicating between cooperating parties but
not directly useful for creating compressed archives, like .zip
files. The built-in compression library does not know how to
format zip archive headers and so on.
This is a simple class library that augments the
System.IO.Compression.DeflateStream class, to provide handling
for Zip files. Using this library, you can write .NET
applications that read and write zip-format files.
The Zip Format
---------------------------------
The zip format is described by PKWare, at
http://www.pkware.com/business_and_developers/developer/popups/appnote.txt
Every valid zipfile conforms to this specification. For
example, the spec says that for each compressed file contained
in the zip archive, the zipfile contains a byte array of
compressed data. (The byte array is something the DeflateStream
class can produce directly.) But the zipfile also contains
header and "directory" information - you might call this
"metadata". In other words, the zipfile must contain a list of
all the compressed files in the archive. The zipfile also
contains CRC checksums, and can also contain comments, and other
optional attributes for each file. These are things the
DeflateStream class, included in the .NET Framework Class
Library, does not read or write.
This Class Library
---------------------------------
The library included here depends on the DeflateStream class,
and extends it to support reading and writing of the metadata -
the header, CRC, and other optional data - defined or required
by the zip format spec.
The key object in the class library is the ZipFile class. The key methods on it:
- AddItem - adds a file or a directory to a zip archive
- AddDirectory - adds a directory to a zip archive
- AddFile - adds a file to a zip archive
- Extract - extract a single element from a zip file
- Read - static methods to read in an existing zipfile, for
later extraction
- Save - save a zipfile to disk
There is also a supporting class, called ZipEntry. Applications
can enumerate the entries in a ZipFile, via ZipEntry. There are
other supporting classes as well. Typically apps do not
directly interact with these other classes.
Using the Class Library
---------------------------------
Check the examples included in this package for simple apps that
show how to read and write zip files. The simplest way to
create a zipfile looks like this:
using(ZipFile zip= new ZipFile(NameOfZipFileTocreate))
{
zip.AddFile(filename);
zip.Save();
}
The simplest way to Extract all the entries from a zipfile looks
like this:
using (ZipFile zip = ZipFile.Read(NameOfExistingZipFile))
{
zip.ExtractAll(args[1]);
}
There are a number of other options for using the class
library. For example, you can read zip archives from streams,
or you can create (write) zip archives to streams. Check the
doc for complete information.
About Directory Paths
---------------------------------
One important note: the ZipFile.AddXxx methods add the file or
directory you specify, including the directory. In other words,
logic like this:
zip.AddFile("c:\\a\\b\\c\\Hello.doc");
zip.Save();
...will produce a zip archive that contains a single file, which
is stored with the relative directory information. When you
extract that file from the zip, either using this Zip library or
winzip or the built-in zip support in Windows, or some other
package, all those directories will be created, and the file
will be written into that directory hierarchy.
If you don't want that directory information in your archive,
then you need to either
(a) copy the file or files to be compressed into the local
directory
(b) change the applications current directory to where the file
resides, before adding it to the zipfile.
The latter involves a call to
System.IO.Directory.SetCurrentDirectory(),
before you call ZipFile.AddXxx().
See the doc:
http://msdn2.microsoft.com/en-us/library/system.io.directory.setcurrentdirectory.aspx
About the Help file
--------------------------------
The .chm file contains help generated from the code.
In some cases, Upon opening the .chm file for DotNetZipLib, the
help items tree loads, but the contents are empty. You may see
an Error: This program cannot display the webpage. If this
happens, it's probable that you encounter problem with Windows
protection of files downloaded from less trusted
location. Within Windows Explorer, right-click on the CHM file,
select properties, and Unblock it (button in lower part of
properties window).
License
--------
This software is released under the Microsoft Permissive License
of OCtober 2006. See the License.txt file for details.
About Other Intellectual Property
---------------------------------
I am no lawyer, but before using this library in your app, it
may be worth contacting PKWare for clarification on rights and
licensing. The specification for the zip format includes a
paragraph that reads:
PKWARE is committed to the interoperability and advancement of the
.ZIP format. PKWARE offers a free license for certain technological
aspects described above under certain restrictions and conditions.
However, the use or implementation in a product of certain technological
aspects set forth in the current APPNOTE, including those with regard to
strong encryption or patching, requires a license from PKWARE. Please
contact PKWARE with regard to acquiring a license.
Contact pkware at: zipformat@pkware.com
This example also uses a CRC utility class, in modified form,
that was published on the internet without an explicit license.
You can find the original CRC class at:
http://www.vbaccelerator.com/home/net/code/libraries/CRC32/Crc32_zip_CRC32_CRC32_cs.asp
Pre-requisites
---------------------------------
to run:
.NET Framework 2.0 or later
to build:
.NET Framework 2.0 SDK or later
or
Visual Studio 2005 or later
Building
---------------------------------
To build this example,
1. extract the contents of this zip into a new directory.
2. be sure the .NET 2.0 SDK and .NET 2.0 runtime directories
are on your path. These are typically
C:\Program Files\Microsoft.NET\SDK\v2.0\bin
and
c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727
3. open a CMD prompt and CD to the zip\Library directory.
4. nmake
5. To build the examples, cd ..\Examples and type nmake again
Building the Help File
--------------------------------------------
If you want to build the helpfile, you need the SandCastle
helpfile builder. Use the DotNetZip.shfb file with SandCastle.
Limitations
---------------------------------
There are numerous limitations to this library:
it does not support encryption, file comments, or double-byte
chars in filenames.
it does not support file lengths greater than 0xffffffff.
it does not support "multi-disk archives."
it does not do varying compression levels.
it can actually expand the size of previously compressed data,
such as JPG files.
there is no GUI tool
and, I'm sure, many others
But it is a good basic library for reading and writing zipfiles
in .NET applications..
And yes, the zipfile that this example is shipped in, was
produced by this example library.
See Also
----------------------------
没有合适的资源?快使用搜索试试~ 我知道了~
DotNetZip [解决了文件名称中文字符不显示的问题]
共175个文件
tfs-base:32个
xml:23个
cs:23个
5星 · 超过95%的资源 需积分: 18 60 下载量 63 浏览量
2009-10-22
11:30:56
上传
评论
收藏 1.56MB RAR 举报
温馨提示
从网上下载了的压缩组件:DotNetZip! 保存中文名称的文件时,要么名称显示不全,要么就显示若干个问号! 经过修改,已解决了这个问题,现共享给大家!! 相关文档: http://blog.csdn.net/redleaf1995/archive/2009/10/22/4712369.aspx
资源推荐
资源详情
资源评论
收起资源包目录
DotNetZip [解决了文件名称中文字符不显示的问题] (175个子文件)
ResolveAssemblyReference.cache 3KB
ResolveAssemblyReference.cache 3KB
testzip.csproj.GenerateResource.Cache 847B
ZipFile.cs 66KB
ZipEntry.cs 44KB
ZipDirEntry.cs 8KB
UnZip.cs 6KB
Shared.cs 5KB
Crc32.cs 4KB
Form1.Designer.cs 3KB
Resources.Designer.cs 3KB
CreateZip.cs 3KB
ZipIt.cs 2KB
ZipDir.cs 2KB
Form1.cs 2KB
ReadZip.cs 2KB
AssemblyInfo.cs 1KB
AssemblyInfo.cs 1KB
AssemblyInfo.cs 1KB
AssemblyInfo.cs 1KB
AssemblyInfo.cs 1KB
AssemblyInfo.cs 1KB
AssemblyInfo.cs 1KB
Settings.Designer.cs 1KB
Program.cs 468B
Constants.cs 408B
#UnZip.cs# 5KB
Library.csproj 4KB
testzip.csproj 4KB
CreateZip.csproj 2KB
ReadZip.csproj 2KB
ZipDir.csproj 2KB
ZipIt.csproj 2KB
UnZip.csproj 2KB
Thumbs.db 10KB
Thumbs.db 6KB
Ionic.Utils.Zip.dll 30KB
Ionic.Utils.Zip.dll 30KB
Ionic.Utils.Zip.dll 30KB
Ionic.Utils.Zip.dll 30KB
Ionic.Utils.Zip.dll 30KB
Ionic.Utils.Zip.dll 30KB
Ionic.Utils.Zip.dll 30KB
Ionic.Utils.Zip.dll 30KB
Ionic.Utils.Zip.dll 10KB
testzip.vshost.exe 14KB
testzip.exe 9KB
testzip.exe 9KB
UnZip.exe 8KB
UnZip.exe 8KB
CreateZip.exe 6KB
CreateZip.exe 6KB
ZipIt.exe 6KB
ZipIt.exe 6KB
ZipDir.exe 6KB
ZipDir.exe 6KB
ReadZip.exe 5KB
ReadZip.exe 5KB
北京地铁地图.jpg 358KB
北京地铁地图.jpg 358KB
桃花.jpg 31KB
桃花.jpg 31KB
redleaf.jpg 3KB
redleaf.jpg 3KB
LastBuild.log 275KB
makefile 605B
testzip.vshost.exe.manifest 490B
Ionic.Utils.Zip.pdb 74KB
Ionic.Utils.Zip.pdb 74KB
Ionic.Utils.Zip.pdb 74KB
Ionic.Utils.Zip.pdb 74KB
Ionic.Utils.Zip.pdb 74KB
Ionic.Utils.Zip.pdb 74KB
Ionic.Utils.Zip.pdb 74KB
Ionic.Utils.Zip.pdb 74KB
testzip.pdb 24KB
testzip.pdb 24KB
CreateZip.pdb 14KB
CreateZip.pdb 14KB
ZipIt.pdb 14KB
ZipIt.pdb 14KB
ReadZip.pdb 14KB
ReadZip.pdb 14KB
UnZip.pdb 14KB
UnZip.pdb 14KB
ZipDir.pdb 14KB
ZipDir.pdb 14KB
testzip.Properties.Resources.resources 180B
testzip.Form1.resources 180B
Form1.resx 6KB
Resources.resx 5KB
Settings.settings 249B
DotNetZip.shfb 2KB
DotNetZip.sln 4KB
DotNetZip.suo 51KB
ZipFile.cs.tfs-base 61KB
ZipEntry.cs.tfs-base 42KB
Setup.vdproj.tfs-base 31KB
ZipDirEntry.cs.tfs-base 8KB
Readme.txt.tfs-base 7KB
共 175 条
- 1
- 2
资源评论
- zhangxiameng2013-06-29感谢楼主分享,解决了中文乱码问题。
- 过境千帆2014-06-22非常好,中文乱码的问题需要自己改一下
redleaf1995
- 粉丝: 39
- 资源: 18
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Cesium 高程为0的地形数据
- 国产化神通数据库-数据库开发手册
- Oracle数据库备份与恢复教程.zip
- 苹果闹铃音乐苹果闹铃音乐
- Unity导入Excel文件自动创建class文件和ScriptObject文件,并转化成ScriptObject的插件pro版
- UE4仅k位移产生完美行走动作-UE4项目
- 基于 Python 的校园导航系统
- tensorflow-2.6.3-cp37-cp37m-manylinux2010-x86-64.whl
- tensorflow-2.6.2-cp39-cp39-win-amd64.whl
- tensorflow-2.6.2-cp39-cp39-manylinux2010-x86-64.whl
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功