7-Zip 简介
7-Zip 是一款号称有着现今最高压缩比的压缩软件,它不仅支持独有的 7z 文件格式,而且还支持各种其它压缩文件格式,其中包括 ZIP, RAR, CAB, GZIP, BZIP2和 TAR 等等。此软件压缩的压缩比要比普通 ZIP 文件高 30-50% ,因此,它可以把 Zip 格式的文件再压缩 2-10% 。
7-Zip 主要特征
更新了算法来加大 7z 格式 的压缩比
支持格式:
压缩及解压缩:7z、ZIP、GZIP、BZIP2 和 TAR
仅解压缩:RAR、CAB、ISO、ARJ、LZH、CHM、WIM、Z、CPIO、RPM、DEB 和 NSIS
对于 ZIP 及 GZIP 格式,7-Zip 能提供比使用 PKZip 及 WinZip 高 2-10% 的压缩比
7z 格式支持创建自释放(SFX)压缩档案
集成 Windows 外壳扩展
强大的的文件管理
强大的命令行版本
支持 FAR Manager 插件
支持 69 种语言
C#中压缩/解压缩7-zip文件的方法
1.控制台方式调用7z.exe文件
public static void Unzip(DirectoryInfo DirecInfo)
{
if (DirectInfo.Exists)
{
foreach (FileInfo fileInfo in DirecInfo.GetFiles(“*.zip”))
{
Process process = new Process();
process.StartInfo.FileName = @”C:\Program Files\7-zip\7z.exe”;
process.StartInfo.Arguments =
@” e C:\Directory\” + fileInfo.Name + @” -o C:\Directory”;
process.Start();
}
}
}
2.根据压缩算法LZMA SDK
LZMA SDK里面包括了压缩和解压缩算法的C#源码(当前版本是4.65)
下载地址:
http://sourceforge.net/projects/sevenzip/files/LZMA%20SDK/4.65/lzma465.tar.bz2/download
3.在.NET应用程序中使用7-Zip的压缩/解压缩功能 (作者 Abel Avram 译者 赵劼 )
开发人员Eugene Sichkar创建了一系列7-Zip动态链接库的C#接口,.NET应用程序中使用7-Zip的压缩/解压缩功能了。
据Eugene称,该项目实现了以下接口:
* IProgress – 基本进度的回调
* IArchiveOpenCallback – 打开压缩包的回调
* ICryptoGetTextPassword – 为压缩提示密码的回调
* IArchiveExtractCallback – 对压缩包进行解压的回调
* IArchiveOpenVolumeCallback – 打开额外压缩卷的回调
* ISequentialInStream – 基本的只读数据流接口
* ISequentialOutStream – 基本的只写数据流的接口
* IInStream – 可以随机读取的输入数据流接口
* IOutStream – 输出数据流接口
* IInArchive – 主要压缩接口
具体的使用方式可以参考源码中示例.
4.SevenZipSharp
markhor 创建了SevenZipSharp 项目,SevenZipSharp 是开源的,里面实现了自解压和压缩所有7-ZIP支持的格式.它改进了7-Zip动态链接库的C#接口的一些方法.
常用压缩/解压缩示例(引自SevenZipSharp示例文件):
解压缩文件
using (SevenZipExtractor tmp = new SevenZipExtractor(@”d:\Temp\7z465_extra.7z”))
{
for (int i = 0; i < tmp.ArchiveFileData.Count; i++)
{
tmp.ExtractFiles(@”d:\temp\!Пусто\”, tmp.ArchiveFileData[i].Index);
}
//tmp.ExtractFiles(@”d:\temp\!Пусто\”, 1, 3, 5);
}
分卷压缩
SevenZipExtractor.SetLibraryPath(@”d:\Work\Misc\7zip\9.04\CPP\”+
7zip\Bundles\Format7zF\7z.dll”);
using (SevenZipExtractor tmp = new SevenZipExtractor(@”d:\Temp\SevenZip.7z.001″))
{
tmp.ExtractArchive(@”d:\Temp\!Пусто”);
}
压缩文件
SevenZipCompressor tmp = new SevenZipCompressor();
tmp.CompressFiles(@”d:\Temp\arch.7z”, @”d:\Temp\log.txt”);
tmp.CompressDirectory(@”c:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\1033″,
@”D:\Temp\arch.7z”);
压缩ZIP文件
SevenZipCompressor tmp = new SevenZipCompressor();
tmp.ArchiveFormat = OutArchiveFormat.Zip;
tmp.CompressFiles(@”d:\Temp\arch.zip”, @”d:\Temp\gpl.txt”, @”d:\Temp\ru_office.txt”);
多线程解压缩
Thread t1 = new Thread(() =>
{
using (SevenZipExtractor tmp = new SevenZipExtractor(@”D:\Temp\7z465_extra.7z”))
{
tmp.FileExtractionStarted += new EventHandler<FileInfoEventArgs>((s, e) =>
{
Console.WriteLine(String.Format(“[{0}%] {1}”,
e.PercentDone, e.FileInfo.FileName));
});
tmp.ExtractionFinished +=
new EventHandler((s, e) => { Console.WriteLine(“Finished!”); });
tmp.ExtractArchive(@”D:\Temp\t1″);
}
});
Thread t2 = new Thread(() =>
{
using (SevenZipExtractor tmp = new SevenZipExtractor(@”D:\Temp\7z465_extra.7z”))
{
tmp.FileExtractionStarted += new EventHandler<FileInfoEventArgs>((s, e) =>
{
Console.WriteLine(String.Format(“[{0}%] {1}”,
e.PercentDone, e.FileInfo.FileName));
});
tmp.ExtractionFinished +=
new EventHandler((s, e) => { Console.WriteLine(“Finished!”); });
tmp.ExtractArchive(@”D:\Temp\t2″);
}
});
t1.Start();
t2.Start();
t1.Join();
t2.Join();
多线程压缩
Thread t1 = new Thread(() =>
{
SevenZipCompressor tmp = new SevenZipCompressor();
tmp.FileCompressionStarted += new EventHandler<FileNameEventArgs>((s, e) =>
{
Console.WriteLine(String.Format(“[{0}%] {1}”,
e.PercentDone, e.FileName));
});
tmp.CompressDirectory(@”D:\Temp\t1″, @”D:\Temp\arch1.7z”);
});
Thread t2 = new Thread(() =>
{
SevenZipCompressor tmp = new SevenZipCompressor();
tmp.FileCompressionStarted += new EventHandler<FileNameEventArgs>((s, e) =>
{
Console.WriteLine(String.Format(“[{0}%] {1}”,
e.PercentDone, e.FileName));
});
tmp.CompressDirectory(@”D:\Temp\t2″, @”D:\Temp\arch2.7z”);
});
t1.Start();
t2.Start();
t1.Join();
t2.Join();
SevenZipSharp – Release: SevenZipSharp 0.58
http://sevenzipsharp.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=32422#DownloadId=81930
VC遍历文件夹下所有文件和文件夹 – 流云の剑舞秋风 – 博客园
http://www.cnblogs.com/yjm0105/archive/2005/06/22/179353.html
HANDLE hFind=::FindFirstFile(szFind,&FindFileData);
if(INVALID_HANDLE_VALUE == hFind) return;
while(TRUE)
{
if(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
if(FindFileData.cFileName[0]!=’.')
{
strcpy(szFile,lpPath);
strcat(szFile,”\\”);
strcat(szFile,FindFileData.cFileName);
find(szFile);
}
}
else
{
cout << FindFileData.cFileName;
}
if(!FindNextFile(hFind,&FindFileData)) break;
}
FindClose(hFind);
VC遍历文件夹下所有文件和文件夹 – 流云の剑舞秋风 – 博客园
http://www.cnblogs.com/yjm0105/archive/2005/06/22/179353.html
C语言帝国: VC 遍历指定目录下的文件
http://www.vcgood.com/forum_posts.asp?TID=2261&PN=1
如何用C实现遍历文件夹? — 编程爱好者论坛存档帖
http://www.programfan.com/club/showpost.asp?id=18098
Windows API一日一练(58)FindFirstFile和FindNextFile函数 – 大坡3D软件开发 – CSDN博客
http://blog.csdn.net/caimouse/archive/2007/10/25/1844006.aspx
CopyHere ignores vOptions – MSDN Forums
https://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1471722&SiteID=1
CodeProject: Decompress Zip files with Windows Shell API and C#. Free source code and programming help
http://www.codeproject.com/KB/cs/decompresswinshellapics.aspx?df=100&forumid=221403&exp=0&select=1405570#xx1405570xx
CodeProject: Decompress Zip files with Windows Shell API and C#. Free source code and programming help
http://www.codeproject.com/KB/cs/decompresswinshellapics.aspx?df=100&forumid=221403&exp=0&select=1405570#xx1405570xx
WinForm程序如何实现自动更新? .NET技术 / C# – CSDN社区 community.csdn.net
http://topic.csdn.net/t/20041222/16/3667425.html
如何使应用程序具有自动更新的功能? .NET技术 / C# – CSDN社区 community.csdn.net
http://topic.csdn.net/t/20020823/14/964523.html
appupdater.aspx
使用Updater Application Block实现自动更新例子 – 昆明小虫 – 博客园
http://www.cnblogs.com/ynlxc/archive/2005/10/31/265252.html
Updater Application Block
自动更新程序的制作方法 – 专注于.Net – 博客园
http://www.cnblogs.com/cxy521/articles/1238247.html
WinForm程序如何实现自动更新? .NET技术 / C# – CSDN社区 community.csdn.net
http://topic.csdn.net/t/20041222/16/3667425.html
Writing a self-updating application in C# By Hendrik Swanepoel
http://www.eggheadcafe.com/articles/pfc/selfupdater.asp
Enterprise Library 3.1 – May 2007
http://msdn.microsoft.com/en-gb/library/aa480453.aspx
WinForm AutoUpdate Strategies : C#, WinForm Auto Update
http://www.experts-exchange.com/Programming/Languages/.NET/Q_23168711.html
Deploying C# Applications
http://msdn.microsoft.com/en-us/library/ms173084(VS.80).aspx
自动更新程序源码下载(C#.Net) – jenry-云飞扬 – 博客园
http://www.cnblogs.com/jenry/archive/2008/10/01/477302.html
VB Helper: HowTo: Shell WinZip to zip and unzip files
http://www.vb-helper.com/howto_shell_zip_and_unzip.html
CodeProject: Decompress Zip files with Windows Shell API and C#. Free source code and programming help
http://www.codeproject.com/KB/cs/decompresswinshellapics.aspx?df=100&forumid=221403&exp=0&select=1583265
Shell32.ShellClass sc = new Shell32.ShellClass(); Shell32.Folder SrcFlder = sc.NameSpace(strSrcPath); Shell32.Folder DestFlder = sc.NameSpace(strDestPath); Shell32.FolderItems items = SrcFlder.Items(); DestFlder.CopyHere(items, 20);
Free Zip component
http://www.xstandard.com/en/documentation/xzip/
VBScript Scripting Techniques: Work with ZIP Files
http://www.robvanderwoude.com/vbstech_files_zip.html
用vbs实现zip_个人交流
http://hi.baidu.com/li_panxue/blog/item/cf303327b29b2607918f9d10.html
用vbs实现zip – 阿强实验室
http://www.hackarea.com/Article/2008/6213.html
VBS显示解压、复制文件的进度[只能解压ZIP文件] – DOS资源站
http://www.cmdos.net/article/sort08/info-1153.html
Sub Extract(ByVal myZipFile, ByVal myTargetDir)
Dim intOptions, objShell, objSource, objTarget
Set objShell = CreateObject("Shell.Application")
Set objSource = objShell.NameSpace(myZipFile).Items()
Set objTarget = objShell.NameSpace(myTargetDir)
intOptions = 256
objTarget.CopyHere objSource, intOptions
Set objShell = Nothing
Set objSource = Nothing
Set objTarget = Nothing
End Sub
\’ System.Shell.Folder.CopyHere() 方法的语法格式:
\’ System.Shell.Folder.copyHere(oItem [, intOptions])
\’ 以下是CopyHere() 方法可用的 intOptions 值, 可参考MSDN (http://msdn2.microsoft.com/en-us/library/ms723207.aspx).
\’ 0: Default. No options specified.
\’ 4: Do not display a progress dialog box.
\’ 8: Rename the target file if a file exists at the target location with the same name.
\’ 16: Click "Yes to All" in any dialog box that is displayed.
\’ 64: Preserve undo information, if possible.
\’ 128: Perform the operation on files only if a wildcard file name (*.*) is specified.
\’ 256: Display a progress dialog box but do not show the file names.
\’ 512: Do not confirm the creation of a new directory if the operation requires one to be created.
\’ 1024: Do not display a user interface if an error occurs.
\’ 4096: Disable recursion. Only operate in the local directory.Don\’t operate recursively into subdirectories.
\’ 9182: Do not copy connected files as a group. Only copy the specified files.
moveHere Method (System.Shell.Folder)
http://msdn.microsoft.com/en-us/library/ms723211(VS.85).aspx
SmartPhone 2003 and .NETcf Primer
http://www.devbuzz.com/Articles/zinc_smartphone_compactframework_pg3.aspx
[Updated 23 Mar 08] Call Firewall + SMS Blocker 1.4 – SmartPhone + MotoQ Versions [Archive] – xda-developers
http://forum.xda-developers.com/archive/index.php/t-307178.html
20080902 c# bzip
CSDN技术中心 在C#中利用SharpZipLib进行文件的压缩和解压缩
http://dev.csdn.net/article/63929.shtm
ICSharpCode.SharpZipLib.BZip2
http://www.componentspot.com/doccenter/SharpZipLib/icsharpcode.sharpziplib.bzip2.html
[翻译]用SharpZipLib(#ZipLib)压缩MemoryStream – 云和山的彼端 – 博客园
http://www.cnblogs.com/jecray/archive/2007/04/15/sharpziplib.html
X3BLOG 多用户版 1.0.0 beta1 /src/SyCODE.Component/Compress.cs
http://www.muchool.com/project/X3BLOG_DYHB/1.0.0+beta1/src/sycode.component/compress.54A17766.cs
Blog
http://cache.baidu.com/c?m=9d78d513d99309f41afa950e0d01d717580ed3237e9f8b57218fc35f93150416183ba3f03023604595852b345ebb0e1cb4ff6c34714137b6e8d595128aead27b649f2743315ed51045920eafbc187e8577875a9efe44b8a7a665c7fd958d994353bd004438cae78a2e1713be3ef21726e4d2c916480a52e9ad7672fe2f2777c2761fe318bff7326a1086828c4b4db57a8e3c44d5fc75f62912b14ff3555d4619e10aa609276070a71830ff407f59d3ad3f9d3d783672ea09a4b9c2c0eb428caaea45eb89c8aa2f916becc1fdf972437752&p=8b2a900d84d811a05fed8c624b07&user=baidu
我们创建一个BZip2 output stream对象,容纳MemoryStream.
BZip2OutputStream zosCompressed = new BZip2OutputStream(msCompressed);
现在我来解说上面报头的含义.在我的实际测试中使,用GZip时,压缩1字节数据需要28字节的额外报头,那些额外的字节是不能被压缩的.用BZip2时,需要36字节的额外报头.实际上,用BZip2可以压缩一个12892字节的源文件到2563字节,有大概75%的压缩率.另一个测试是从730字节压缩到429字节,最后一个测试是174字节到161字节.显然,任何压缩需要额外的可用空间.
下面我们将数据写入BZip2OutputStream
string sBuffer = "This represents some data being compressed."
byte[] bytesBuffer = Encoding.ASCII.GetBytes(sBuffer);
zosCompressed.Write(bytesBuffer, 0, bytesBuffer.Length);
zosCompressed.Finalize();
zosCompressed.Close();
由于要用到IO和stream方法,要使用字节数组替代字符串.所以我们用字节数组作为输出,然后将压缩的流写入内存流.
bytesBuffer = msCompressed.ToArray();
string sCompressed = Encoding.ASCII.GetString(bytesBuffer);
这样内存流中包含了压缩过的数据,我们将数据用字符数组输出,然后转换成字符串.要注意,这个字符串是乱码,不可读的.如果你想查看数据,我用的方法是把它转换为Base64编码的数据,但是这样会增加大小.运行程序使43字节的未压缩数据变成74字节的压缩数据,如果用base 64编码,会得到100字节的结果:
QlpoOTFBWSZTWZxkIpsAAAMTgEABBAA+49wAIAAxTTIxMTEImJhNNDIbvQ
aWyYEHiwN49LdoKNqKN2C9ZUG5+LuSKcKEhOMhFNg=
解压缩
MemoryStream msUncompressed =
new MemoryStream(Encoding.ASCII.GetBytes(sCompressed));
BZip2InputStream zisUncompressed = new BZip2InputStream(msUncompressed);
bytesBuffer = new byte[zisUncompressed.Length];
zisUncompressed.Read(bytesBuffer, 0, bytesBuffer.Length);
zisUncompressed.Close();
msUncompressed.Close();
string sUncompressed = Encoding.ASCII.GetString(bytesBuffer);
这样sUncompressed将被解压到原始的字符串.文件也是相同的原理.
今日百度招聘有感 – 云和山的彼端 – CSDNBlog
http://blog.csdn.net/jecray/archive/2007/04/06/1554578.aspx
字符串(string)压缩 .NET技术 / C# – CSDN社区 community.csdn.net
http://topic.csdn.net/t/20060214/14/4555387.html
//压缩
public static string Compress(string uncompressedString)
&leftsign;
byte[] bytData = System.Text.Encoding.Unicode.GetBytes(uncompressedString);
MemoryStream ms = new MemoryStream();
Stream s = new ICSharpCode.SharpZipLib.BZip2.BZip2OutputStream(ms);
s.Write(bytData, 0, bytData.Length);
s.Close();
byte[] compressedData = (byte[])ms.ToArray();
return System.Convert.ToBase64String(compressedData, 0, compressedData.Length);
&rightsign;
//解压
public static string DeCompress(string compressedString)
&leftsign;
System.Text.StringBuilder uncompressedString = new System.Text.StringBuilder();
int totalLength = 0;
byte[] bytInput = System.Convert.FromBase64String(compressedString);;
byte[] writeData = new byte[4096];
Stream s2 = new ICSharpCode.SharpZipLib.BZip2.BZip2InputStream(new MemoryStream(bytInput));
while (true)
&leftsign;
int size = s2.Read(writeData, 0, writeData.Length);
if (size > 0)
&leftsign;
totalLength += size;
uncompressedString.Append(System.Text.Encoding.Unicode.GetString(writeData,0,size));
&rightsign;
else
&leftsign;
break;
&rightsign;
&rightsign;
s2.Close();
return uncompressedString.ToString();
&rightsign;
compression helper…improved version (SharpZipLib)
http://www.xmlasp.net/n1492c13.aspx
使用ICSharpCode.SharpZipLib.dll实现在线解压缩_程序员之家
http://hi.baidu.com/xiao_wei2008/blog/item/307a881fa80dee66f624e422.html
在C#中怎么利用SharpZipLib进行字符串的压缩和解压缩
http://topic.csdn.net/u/20070307/18/8a96353a-cf0a-406c-80f4-255a1ef92a29.html
http://www.icsharpcode.net/OpenSource/SharpZipLib/Download.aspx
In a Class of its own – the .NET Zip Library
http://www.aspheute.com/english/20011115.asp
Sipo Blog-ASP.NET下Zip,GZip,BZip2,Tar的实时压缩与解压缩
http://www.dc9.cn/view.asp?id=332
20080509 c# zip gzip
http://www.yippeesoft.com
http://www.techtalkz.com/c-c-sharp/111112-zip-file-using-stream.html
Zip file using a stream
http://www.codeproject.com/KB/dotnet/mscompression.aspx
MemoryStream Compression
http://community.sharpdevelop.net/forums/p/5273/15129.aspx#15129
Compress MemoryStream and what is best method
http://www.pcreview.co.uk/forums/thread-1300944.php
Reply
Zipping and unzipping
http://mastercsharp.com/article.aspx?ArticleID=86&TopicID=16
/ The actual ZIP method
private byte[] Zip(string stringToZip)
&leftsign;
byte[] inputByteArray = Encoding.UTF8.GetBytes(stringToZip);
MemoryStream ms = new MemoryStream();
// Check the #ziplib docs for more information
ZipOutputStream zipOut = new ZipOutputStream( ms ) ;
ZipEntry ZipEntry = new ZipEntry("ZippedFile");
zipOut.PutNextEntry(ZipEntry);
zipOut.SetLevel(9);
zipOut.Write(inputByteArray, 0 , inputByteArray.Length ) ;
zipOut.Finish();
zipOut.Close();
// Return the zipped contents
return ms.ToArray();
&rightsign;
http://www.cnblogs.com/shawb/articles/140881.html
在线压缩文件
http://www.w3sky.com/2/2505.html
实时zip压缩下载整个目录
http://community.icsharpcode.net/forums/p/3147/9246.aspx
Creating a Zip containing files with special characters
int转换成长度为4的byte数组,长度为4的byte数组合成一个int.
static int bytes2int(byte[] b)
&leftsign;
//byte[] b=new byte[]&leftsign;1,2,3,4&rightsign;;
int mask=0xff;
int temp=0;
int res=0;
for(int i=0;i<4;i++)&leftsign;
res<<=8;
temp=b[i]&mask;
res&line;=temp;
&rightsign;
return res;
&rightsign;
static byte[] int2bytes(int num)
&leftsign;
byte[] b=new byte[4];
int mask=0xff;
for(int i=0;i<4;i++)&leftsign;
b[i]=(byte)(num>>>(24-i*8));
&rightsign;
return b;
&rightsign;
将一个包含ASCII编码字符的Byte数组转化为一个完整的String,可以使用如下的方法:
using System;
using System.Text;
public static string FromASCIIByteArray(byte[] characters)
&leftsign;
ASCIIEncoding encoding = new ASCIIEncoding( );
string constructedString = encoding.GetString(characters);
return (constructedString);
&rightsign;
将一个包含Unicode编码字符的Byte数组转化为一个完整的String,可以使用如下的方法:
public static string FromUnicodeByteArray(byte[] characters)
&leftsign;
UnicodeEncoding encoding = new UnicodeEncoding( );
string constructedString = encoding.GetString(characters);
return (constructedString);
&rightsign;
http://skyivben.cnblogs.com/archive/2005/09/17/238828.html
使用C#2.0进行文件压缩和解压
http://www.cnblogs.com/jeet/default.html?page=5
压缩数据,提升Web service性能
http://www.hackhome.com/InfoView/Article_8519_2.html
在C#中利用SharpZipLib进行文件的压缩和解压缩
http://www.w3sky.com/2/2505.html
实时zip压缩下载整个目录
http://www.winimage.com/zLibDll/minizip.html
Minizip: Zip and UnZip additionnal library
http://www.codeproject.com/KB/files/sharpzlib.aspx
#zlib – Modifying Archives
http://www.vbfrance.com/codes/ZLIB-NET-COMPRESSION-ZIP-AVEC-VB-NET_46397.aspx
ZLIB.NET : COMPRESSION ZIP AVEC VB.NET
http://www.cnblogs.com/Magicsky/archive/2007/07/08/810274.html
不依赖OFFICE组件实现带图片的EXCEL导出
文件下载时用的Http头
HttpResponse.AddHeader("content-disposition", "attachment;filename=" + filename)
标签:c++, gzip, zip20080326 gzip ICSharpCode 日历控件
http://www.yippeesoft.com
GZip
加入ICSharpCode.SharpZipLib.dll的引用,在#Develop的安装目录下的\\SharpDevelop\\bin目录下。然后在程序中使用using语句把GZip类库包含进来。
由于GZip没有BZip2的简单解压缩方法,因此只能使用流方法来进行解压缩。具体的方法见程序的说明。
编译程序,然后在命令行方式下输入GZip 文件名(假设建立的C#文件是GZip,就可以生成压缩文件;输入GZip -d 文件名,就会解压出文 件来(-d是用来表示解压,你也可以使用其他的符号)。
using System;
using System.IO;
using ICSharpCode.SharpZipLib.GZip;
class MainClass
&leftsign;
public static void Main(string[] args)
&leftsign;
if (args[0] == "-d") &leftsign; // 解压
Stream s = new GZipInputStream(File.OpenRead(args[1]));
//生成一个GZipInputStream流,用来打开压缩文件。
//因为GZipInputStream由Stream派生,所以它可以赋给Stream。
//它的构造函数的参数是一个表示要解压的压缩文件所代表的文件流
FileStream fs = File.Create(Path.GetFileNameWithoutExtension(args[1]));
//生成一个文件流,它用来生成解压文件
//可以使用System.IO.File的静态函数Create来生成文件流
int size = 2048;//指定压缩块的大小,一般为2048的倍数
byte[] writeData = new byte[size];//指定缓冲区的大小
while (true) &leftsign;
size = s.Read(writeData, 0, size);//读入一个压缩块
if (size > 0) &leftsign;
fs.Write(writeData, 0, size);//写入解压文件代表的文件流
&rightsign; else &leftsign;
break;//若读到压缩文件尾,则结束
&rightsign;
&rightsign;
s.Close();
&rightsign; else &leftsign; // 压缩
Stream s = new GZipOutputStream(File.Create(args[0] + ".gz"));
//生成一个GZipOutputStream流,用来生成压缩文件。
//因为GZipOutputStream由Stream派生,所以它可以赋给Stream。
FileStream fs = File.OpenRead(args[0]);
/生成一个文件流,它用来打开要压缩的文件
//可以使用System.IO.File的静态函数OpenRead来生成文件流
byte[] writeData = new byte[fs.Length];
//指定缓冲区的大小
fs.Read(writeData, 0, (int)fs.Length);
//读入文件
s.Write(writeData, 0, writeData.Length);
//写入压缩文件
s.Close();
//关闭文件
&rightsign;
&rightsign;
&rightsign;
使用ICSharpCode.SharpZipLib.dll实现在线解压缩
http://blog.csdn.net/MaleLionOfWakeUp/archive/2008/03/18/2193480.aspx
http://www.dc9.cn/post/Python-gzcompress-php-net.html
总算在C#.NET,Python,Ruby上实现了php的zlib的gzcompress函数
PRB: 工具箱或菜单项是 VisualBasic IDE 中缺少
症状
当您打开 VisualBasic 项目, 您将不能查看工具箱或几项是从菜单选项丢失。
回到顶端
原因
此问题的一个可能的原因是注册表损坏。
回到顶端
解决方案
要重置为其默认设置, 选项请按照下列步骤操作:
1. 右击主菜单栏并选择 自定义 。 自定义 对话框打开。
2. 选择 工具栏 选项卡并单击 Reset 按钮。
3. 自定义 对话框保持打开, 右击要在主菜单栏 (例如, 文件、 编辑和等等), 重置, 然后选择 重置 选项所有菜单选项。
4. 关闭 自定义 对话框。
I can no longer make exe\’s in VB6. The Make exe item on the File menu is
grayed out. I have been creating exe files for at least a year on this
machine, but suddenly no go. I did have a few VB crashes when I was working
on creating an OCX. I\’m guessing that one of these crashes caused the
problem. The only way to make an executable now is to have my project in a
project group. I can then Make Project Group and select the project that I
want. It\’s a pain for project groups with lots of projects, however.
http://support.microsoft.com/kb/266747/en-us
http://blog.csdn.net/kimsoft/archive/2006/05/24/753225.aspx
[2008-03-22更新]一个JavaScript WEB日历控件,支持IE6,FireFox,可支持不同语言版本,目前支持中英文
http://www.notii.com/2007/05/top-5-javascript-framework.html
Top 5 Javascript 框架
ExtJS(http://extjs.com/)和DWR( http://www.getahead.ltd.uk/dwr/)。
http://www.open-open.com/67.htm
Java开源AJAX框架
http://blog.csdn.net/cityhunter172/archive/2006/11/28/1417752.aspx
推荐兼容 IE、 FireFox 的 javascript 日历控件
http://blog.csdn.net/cityhunter172/archive/2006/11/28/1417752.aspx
http://code.google.com/p/kimsoft-jscalendar/downloads/list
http://dev.csdn.net/author/Jason009/65c69cc4e34a4ef783c45add211105e0.html
gzip压缩算法
http://ms.mblogger.cn/downmoon/posts/19951.aspx
http://hi.baidu.com/huohuoluo/blog/item/122bf562f40946dde6113a42.html
一个不错的js日期控件
http://www.cnblogs.com/xgpapa/archive/2007/08/07/846985.html
超级简单好用的JS日期控件
http://hi.baidu.com/sunweiliang/blog/item/d181d5b49b4d7c778ad4b2c5.html
js 日期控件
http://dev2dev.bea.com.cn/bbs/thread.jspa?forumID=121&threadID=36592
JS日期控件
http://www.iusesvn.com/html/02/9502-2640.html
SVN总结
20080324 ICSharpCode GZipStream
http://www.yippeesoft.com
http://www.cnblogs.com/DreamlikeAttic/archive/2006/07/07/445643.html
在Pocket PC/Smartphone智能设备上编写压缩程序(特别简单,任何人都能简单使用)
2.0里内置了DeflateStream GZipStream压缩算法,没有压缩比的选择,实验了一下一个49,934字节的文件,用gzipstream压缩后35,964,用deflatestream压缩后35,946,用winrar3.62最大压缩26,598,7-zip也可以压缩成gzip,用7-zip选择压缩成gzip并最大压缩后26,485,比winrar都强。显得2.0自带的这个算法真是没用啊。
但是好玩的是,.net里用gzipstream却可以解压用7-zip压缩的gz,这样就可以用7-zip压缩成gz给工程用,比如作成资源,然后光用.net的解压就可以了
xml文件操作时挺有用,可以压缩减少文件尺寸。
压缩:
public static string Compress(string code_type, string text)
&leftsign;
byte[] buffer = Encoding.GetEncoding(code_type).GetBytes(text);
MemoryStream ms = new MemoryStream();
using (GZipStream zip = new GZipStream(ms, CompressionMode.Compress, true))
&leftsign;
zip.Write(buffer, 0, buffer.Length);
&rightsign;
ms.Position = 0;
MemoryStream outStream = new MemoryStream();
byte[] compressed = new byte[ms.Length];
ms.Read(compressed, 0, compressed.Length);
byte[] gzBuffer = new byte[compressed.Length];
System.Buffer.BlockCopy(compressed, 0, gzBuffer, 0, compressed.Length);
return Convert.ToBase64String(gzBuffer);
&rightsign;
解压:
public static string Decompress(string code_type, string compressedText)
&leftsign;
byte[] gzBuffer = Convert.FromBase64String(compressedText);
using (MemoryStream ms = new MemoryStream())
&leftsign;
int msgLength = BitConverter.ToInt32(gzBuffer, 0);
ms.Write(gzBuffer, 0, gzBuffer.Length );
byte[] buffer = new byte[msgLength];
ms.Position = 0;
using (GZipStream zip = new GZipStream(ms, CompressionMode.Decompress))
&leftsign;
zip.Read(buffer, 0, buffer.Length);
&rightsign;
return Encoding.GetEncoding(code_type).GetString(buffer);
&rightsign;
著名的压缩库ICSharpCode.SharpZipLib.GZip我是没有试出来,我认为他没有提供这种不包含头的压缩功能。我压缩出来的都是包含头的。于是我再次寻找到了zlib.net.dll这个是从http://www.zlib.net/官方网站找到的,果然什么东西都得用官方的!
那么代码就是这样的
byte[] byteData = System.Text.Encoding.UTF8.GetBytes("http://www.dc9.cn");
MemoryStream ms = new MemoryStream();
Stream s = new ZOutputStream(ms, 9);
s.Write(byteData, 0, byteData.Length);
s.Close();
byte[] compressData = (byte[])ms.ToArray();
ms.Flush();
ms.Close();
FileStream fileStream = new FileStream("C:\\\\dc9.cn.zip", FileMode.Create, FileAccess.Write);
Console.Write(System.Convert.ToBase64String(compressData, 0, compressData.Length));
fileStream.Write(compressData, 0, compressData.Length);
fileStream.Flush();
fileStream.Close();
我最先想到的是.net framework2.0以来新加入的一个System.IO.Compression;这里面的GZipStream 不提供level,不提供无头压缩。很郁闷。这个压缩出来是直接能用winrar解压的。带头的才能winrar/winzip解压。
FileStream fileStream = new FileStream("C:\\\\dc9.cn.zip",FileMode.Create,FileAccess.Write);
MemoryStream ms = new MemoryStream();
GZipStream compressionStream = new GZipStream(ms,CompressionMode.Compress);
StreamWriter writer = new StreamWriter(compressionStream);
writer.Write("http://www.dc9.cn");
writer.Close();
fileStream.Write(ms.ToArray(), 0, ms.ToArray().Length);
fileStream.Flush();
fileStream.Close();
using ICSharpCode.SharpZipLib.GZip;这个我懒得说了,也是带头的
关键就是
FileStream destinationStream = new FileStream("C:\\\\dc9.cn.zip",FileMode.OpenOrCreate);
GZipOutputStream outStream = new GZipOutputStream(destinationStream);
outStream.Write(buffer, 0, buffer.Length);
outStream.Flush();
outStream.Finish();
20080219 vb vc zip
http://www.yippeesoft.com
http://www.codeguru.com/vb/gen/vb_graphics/fileformats/article.php/c6743
This code shows how to use the freeware InfoZip Zip32.DLL and Unzip32.DLL files from the
http://www.vbaccelerator.com/home/VB/Utilities/VBPZip/VBPZip_Source_Code.asp
ip file: VBPZip Source Code.zip
http://www.vckbase.com/sourcecode/algorithms/
CZip和CUnzip的源代码
目标动态库输出两个类: CZip(用于压缩文件) CUnzip (用于解压缩文件)使用gzip GNU源代码(gzip-1.2.4a)。这是个免费软件,你可以在GUN通用公共许可证(General Public License)条款下分发和修改此软件。
hSource = LZOpenFile("c:\\myfile.tx_", SourceStruct, OF_READ)
hDest = LZOpenFile("c:\\myfile.tx", DestStruct, OF_CREATE)
\’Copy the files
lResults = LZCopy(hSource, hDest)
\’Close the files
LZClose hSource
LZClose hDest
\’Check for errors
Select Case lResults
Case LZERROR_BADINHANDLE
MsgBox "LZERROR_BADINHANDLE"
Case LZERROR_BADOUTHANDLE
MsgBox "LZERROR_BADOUTHANDLE"
Case LZERROR_BADVALUE
MsgBox "LZERROR_BADVALUE"
Case LZERROR_GLOBLOCK
MsgBox "LZERROR_GLOBLOCK"
Case LZERROR_PUBLICLOC
MsgBox "LZERROR_PUBLICLOC"
Case LZERROR_READ
MsgBox "LZERROR_READ"
Case LZERROR_UNKNOWNALG
MsgBox "LZERROR_UNKNOWNALG"
Case LZERROR_WRITE
MsgBox "LZERROR_WRITE"
End Select
End Sub
http://gnuwin32.sourceforge.net/packages/zlib.htm
Zlib for Windows
zlib is designed to be a free, general-purpose, legally unencumbered — that is, not covered by any patents — lossless data-compression library for use on virtually any computer hardware and operating system. The zlib data format is itself portable across platforms. Unlike the LZW compression method used in Unix compress(1) and in the GIF image format, the compression method currently used in zlib essentially never expands the data. (LZW can double or triple the file size in extreme cases.) zlib\’s memory footprint is also independent of the input data and can be reduced, if necessary, at some cost in compression.
1. 如何获得zlib
zlib的主页是:http://www.zlib.net/
2. 用VC++6.0打开
把 下载的源代码解压打开,VC6.0的工程已经建好了,在\\projects\\visualc6. 双击zlib.dsw, 可以在VC++6.0中看到里面有3个工程: zlib 是库文件(编译设置选中 win32 lib debug / release), 工程example 是如何使用 zlib.lib 的示例, 工程minigzip 是如何用 zlib 提供的函数读写.gz文件的示例(*.gz的文件一般Linux下比较常用).
http://www.kaola.cn/u/smallarmy/282388
http://www.codeproject.com/KB/library/LiteZip.aspx?fid=278047&df=90&mpp=25&noise=3&sort=Position&view=Quick&fr=51#xx0xx
LiteZip/LiteUnzip
LiteZip.dll and LiteUnzip.dll are two Win32 Dynamic Link libraries. The former has functions to create a ZIP archive (ie, compress numerous files into a ZIP file). The latter has functions to extract the contents of a ZIP archive.
This project is largely based upon work by Lucian Wischik, who in turn based his work on gzip 1.1.4, zlib, and info-zip which are by by Jean-Loup Gailly and Mark Adler. Lucian\’s code has been reworked to be written in plain C, using only the Win32 API, and packaged into 2 DLLs. (Also some improvements to error-checking, some added functionality, and code-reduction/stream-lining was accomplished).
http://www.codeproject.com/KB/cpp/xzipunzip.aspx
XZip and XUnzip – Add zip and/or unzip to your app with no extra .lib or .dll
have already introduced XZip in a previous article. This article presents XZip and also XUnzip, which together allow you to add zip and unzip to your application without using any .lib or .dll.
First, let me acknowledge the work of Lucian Wischik, who took the many .c and .h files from Info-ZIP and produced the .cpp and .h files that XZip is based on.
Zip and Unzip in the MFC way
http://www.codeproject.com/KB/recipes/zip.aspx
This library allows creating, modifying and extracting zip archives in the compatible way with PKZIP (2.5 and higher) and WinZip. Supported are all possible operations on the zip archive: creating, extracting, adding, deleting files from the archive, modifications of the existing archive. There is also the support for creating and extracting multiple disk archives (on non-removable devices as well) and for password encryption and decryption. This module uses compression and decompression functions from zlib library by Jean-loup Gailly and Mark Adler.
How to integrate with the project
Zip is a static library and statically links to compiled zlib.lib (version 1.13 nowadays). The zlib library can be replaced with a newer version providing you also replace the files: "zlib.h" and "zconf.h" in the Zip project. The Zip library uses MFC in a shared library as a Release and Debug Configuration. Your project must use MFC in the same way in the appropriate project configuration. You may need to adapt this to your needs. To add Zip library functionality to your project you need to link the library to the project. You can do this in at least two ways (in both cases you need to include ZipArchive.h header in your sources like this: #include "ZipArchive.h"):
Content and Component Delivery SDK
Microsoft Cabinet SDK
一个在MFC环境中使用的 InfoZip打包类,InfoZip是一个功能强大的免费ZIP/UNZIP库。为了方便它的使用,在此介绍一个InfoZip的打包类 CInfoZip,这个类本身并不实现压缩功能,只是提供一个易于使用的InfoZip DLLs接口(包含在CInfoZip中)。CInfoZip类的使用方法请参见相关文章。
http://vckbase.com/code/viewcode.asp?id=1480
软件开发误区之三-操作系统之争 http://www.yippeesoft.com/blog/p/mydevsoft3.php 我写到:
第一:后台老板,WINDOWS的后台是微软,LINUX的后台增加了IBM等,不论LINUX的初衷如何,现在也是商人在弄,商人的目的是什么,是利润。大家都不会只是守在自己的得势地盘的。只要能够赚钱,不断的会扩充的。IBM当年的名言:全世界有几天IBM的大型计算机就足够了。自从当年决策失误,让微软得势,一直耿耿在怀,所以IBM自己操作系统Ohttp://www.yippeesoft.comVER后,一直对桌面系统有兴趣。它的兴趣目前只是在于推出自己硬件设备,卖自己的系统服务,而我觉得它的目的是先用LINUX打击WINDOWS,然后再逐步扩充自己的系统。而我们吵来吵去,都是给人家当枪使唤。
平时我总是认为:微软最伟大的地方就是创造了程序员这个职业,把它从大学研究室、大机构信息中心等象牙塔中解放出来;我们鼓吹LINUX开源,实际上是 剜得心头肉,补缺眼前疮;而我们争论微软、LINUX正如两个虫子争论是被乌鸦吃掉还是喜鹊吃掉高尚一些好一些~~ www.yippeesoft.com
今天看到这个:[quote]IT时代周刊:生或死 中国Linux必须作出抉择 IT时代周刊》记者/宋保强(发自北京)
此前,中国政府支持Linux的做法的确受到诸多质疑。8月底,有业界人士提交报告呼吁政府重新考虑“优先选择开源软件”的政策。该报告指出:中国政府对开源Linux平台的“过度偏爱”正在伤害民族软件产业,因为其免费和低费用销售导致软件价值普遍被低估,Linux商业模式存在的缺陷正在影响Linux供应商的收益,使其陷于经营亏损的怪圈。据业界猜测,这份报告可能就是2005年8月23日,中国软件行业协会出台的《有关开放源代码软件与商业软件知识产权的研究报告》。
决定世界Linux生死的幕后操盘手
张先民出身于在幕后大力支持Linux发展的IBM公司。业界认为,IBM对任何Linux公司能否成功发展起着至关重要的作用。
当微软从IBM手里夺过世界软件业霸主的王座后,很多人以为IBM支持Linux发展是基于长远战略的考虑,一位资深的Linux人士却并不这样认为,他告诉本刊记者:“是在进攻IBM已经不能说,他们支持Linux实质是一种防守行为。”他举例说,IBM的数据库跑在Windows平台上非常慢,原因很简单,微软也在卖自己的数据库。“这只是一个例子,背后的东西更多。”他意味深长地说。
事实上,甲骨文公司也是最早大力支持Linux的厂商之一,但经过一段时间的摸索后,他们通过并购Peoplesoft等商务软件公司,完成了向软件与咨询业产业链上游转移的目标,伴随中间件等技术的不断完善,其不再拘泥于与微软的操作系统平台之争,而将竞争的注意力转向SAP、IBM的传统大型商务软件市场,因此甲骨文已慢慢淡化了其与微软的直接交锋和对Linux的狂热拥护。
此外,Sun也同样是初期开源世界和Linux的重要鼓噪者,并提出了“高端Solaris+低端Linux”的双层产品计划,可经过一段时期的市场发展,Sun逐渐认识到Linux的异军突起并没有给微软以打击,反而逐步吞噬了包括Solaris在内的传统UNIX的份额,造成UNIX大幅度下滑的尴尬局面。有鉴于此,他们立即与微软达成和解,并马上掉转枪口指向Linux。但归根结底,Linux幕后真正的较量者依旧是IBM和微软。
微软本是Linux最大的敌人,以IBM为首的Linux军团也确实在短期内纠集了大量知名IT巨头,发动针对微软的、谋求世界IT霸权的“圣战”。一时间,微软风声鹤唳,从盖茨、鲍尔默到微软操作系统部门都“谈Linux色变”,而微软虽贵为软件皇帝,但要同时对抗如此多的诸侯,也是件不可能完成的任务。可是,在IBM扭亏、甲骨文别恋、Sun投诚的时候,微软意识到Linux并非想象中的可怕,因此也就随即软化了原本对Linux恶毒诅咒的强硬态度,发出可与开源世界和解、共存的和平信号。
而像英特尔、惠普、戴尔和NEC等,原本就是微软的忠实伙伴,要么是一同统治世界的坚定战友,要么是跟随微软发家致富的利益同盟,他们表态支持Linux无非是希望以此限制微软不断膨胀的市场野心,并在与微软的合作中谋求更多利益。
如此一来,原本泰坦林立的众神之战,已经蜕变为IBM支持的红帽、Novell,与微软支持的Sun之间的“代理人”之战,而战争局势也由微软一力对抗整个IT世界转变为微软盟军围剿IBM与Linux。
IBM在支持Linux的时候没有和微软直面交锋,而是躲在幕后积极扶持红帽公司。IBM最初的Linux战略是单一支持红帽,但红帽做大后并不甘心扮演“蓝色巨人”的跟班。在IBM洞悉此事后,开始转而支持Novell收购SuSE,并力促Novell成为世界第2大Linux厂商,还同时支持拓林思抢占中国高端市场,从而形成商业Linux的三驾马车,分别割据北美(红帽)、欧洲(SuSE)和亚太(拓林思)。不过,由于在全球范围内与微软竞争需要消耗IBM大量资源,IBM放弃了3家中最弱小的拓林思,改为着重扶持红帽和Novell,并通过大力推动“开源开放实验室”(以下简称OSDL)实现间接影响全球Linux趋势。这也就是目前Linux业界的现状——红帽和Novell掌握了世界开源系统市场话语权。
[/quote]
阿甘,你真他妈的是个天才! www.yippeesoft.com
QQ2005 Beta3软件安全性的声明
3、 为了给用户最好的体验,提高运行速度和减少响应时间,“QQ地址栏搜索”插件采用了Windows标准的接口,随着操作系统启动自动运行。同时,该插件还采用了“动态文件名”技术,以防止一些恶意插件和程序的强行修改和删除。该插件在运行中与服务器的通讯仅为自身升级所用,绝对不会收集和发送任何有关用户隐私的信息,不会侵害用户的任何利益,不会修改用户的任何安全设置。
我不懂什么东西,不过作为一个八年经验的开发人员,第一次听过:“动态文件名”技术 长见识 www.yippeesoft.com
今天看到一个 RARFS软件 可以让资源管理器把RAR文件当作文件夹处理…
不禁让我想起以前的zipmagic ZipMagic将压缩文件包当成Windows中文件夹来看待,每一个压缩文件都是一个文件夹。注意,当安装了ZipMagic后,Windows系统都将ZIP压缩文件包认为是一个文件夹,并具有文件夹的属性。但在某些时候,例如选择文件时,就不会把ZIP文件当成一个独立的数据文件,这时候,就要使ZipMagic休眠,ZIP文件才会成为一个独立的数据文件。
不过现在已经没有什么声音了,我觉得太占用资源了,而RAR相比ZIP,解压压缩速度更加慢,不知道这个软件如何? www.yippeesoft.com
说到ZIPMAGIC,不禁想起以前做的ISDN配置程序,就是仿照它的配置对话框,左边是一个LISTVIEW小ICON列表,右边是对话框,通过ICON切换。当时我硬是在右边放了一百多个控件然后逐个进行显示控制 ,真是土啊~~ www.yippeesoft.com
标签:agi, linux, magic, zip, 动态, 文件今天的搜索来源 GOOGLE 120 百度 59 验证了我的一些看法:相对而言,GOOGLE比较没有什么推广之类的;而编程方面使用GOOGLE的也比较多
GMAIL:目前您已经使用了2202 MB中的100 MB(5%)。50份邀请函剩余 可惜没有人要
发送一些邮件给GMAIL总是失败:This message is generated by COREMAIL email system.
I\’m sorry to have to inform you that the message returned
The message to yippeesoft@gmail.com is bounced because : SMTP error, DOT: 552 5.7.0 Illegal Attachment
无论是RAR还是ZIP,我改名成1RAR之类的才能发送正常,原因如下:本来想作个插件作这个事情的,后来想想还是算了~~~~~
作为预防可能存在的病毒的一种安全手段,Gmail 不允许用户接收可能包含破坏性可执行代码的可执行文件(例如文件名以 .exe 结束的文件)。
即使这些类型的文件以压缩格式(.zip、.tar、.tgz、.taz、.z、.gz)发送,Gmail 也不会接收。如果有任何这种类型的邮件发送到了您的 Gmail 帐户,该邮件会退回发送方。
大多数计算机病毒包含在可执行文件中,因此,一般的病毒检测程序都是对邮件进行扫描,查找怀疑是病毒的可执行文件。Gmail 采用几乎是最直接的方式拦截病毒:不让用户接收可能包含破坏性可执行代码的可执行文件(例如文件名以 .exe 结束的文件)。这不仅保护了您的计算机,也终止了这些病毒的传播。
即使这些类型的文件以压缩格式(.zip、.tar、.tgz、.taz、.z、.gz)发送,Gmail 也不会接收。如果可执行文件发送到了您的 Gmail 帐户中,该邮件会退回发送方。
这样看了GOOGLE应该取得了RAR的授权,WINZIP为什么打败不了WINRAR,主要原因就是ZIP文件格式是开放的,而RAR文件格式受版权保护的,一个小原因就是RAR的压缩率比ZIP高;但是WINZIP的压缩速度远远高于RAR。
今天发现VB的MSCOMM控件的一个问题:如果放上一个MSCOMM控件,FORM LOAD事件里面 PORTOPEN=TRUE,以及RThreshold=1用来激活MSComm_OnComm 在Case comEvReceive \’ 收到 RThreshold # ofchars. 写上UNLOAD ME。然后放上一个按钮 CommandButton 控件,在_Click 事件里面OUTPUT="AT"+CHR(13) 发送一条指令,立即VB就会出现非法错误,WIN2K下是提示读写访问了不能禁止访问不能写入的内存,地址是多少多少;XP就是提示出现VB需要关闭,出现严重错误,是否需要关闭之类的。可能是因为此时控件正在执行事件当中,而UNLOAD ME则卸载了控件,导致如此。以我微薄的VC编程经验来看,这种事件应该是开启了一个线程访问COM口,监听COMEVENT各种事件,此时卸载窗体类似于这个进程被杀掉,而线程没有完全退出和释放。具体不是很清楚,反正加了一个定时器作为退出。
标签:com, gmail, google, mscomm, zip