asp.net文件和文件夹压缩调用类库ICSharpCode.SharpZipLib.dllusingSystem.IO;usingICSharpCode.SharpZipLib;usingICSharpCode.SharpZipLib.Checksums;usingICSharpCode.SharpZipLib.Zip;usingICSharpCode.SharpZipLib.GZip;usingICSharpCode.SharpZipLib.BZip2;usingICSharpCode.SharpZipLib.Zip.Compression;usingICSharpCode.SharpZipLib.Zip.Compression.Streams;protectedvoidButton1Click(objectsender,EventArgse){string[]str=newstring[1];str[0]=@"E:\9541241560\地学院\";Zip(str);}#region压缩//////压缩文件,默认目录为当前目录,文件名为当前目录名,压缩级别为6//////要压缩的文件或文件夹publicvoidZip(paramsstring[]fileOrDirectory){Zip(6,fileOrDirectory);}//////压缩文件,默认目录为当前目录,文件名为当前目录名//////压缩的级别///要压缩的文件或文件夹publicvoidZip(intzipLevel,paramsstring[]fileOrDirectory){if(fileOrDirectory==null)return;elseif(fileOrDirectory.Length<1)return;else{stringstr=fileOrDirectory[0];if(str.EndsWith("\\"))str=str.Substring(0,str.Length-1);str+=".zip";Zip(str,zipLevel,fileOrDirectory);}}//////压缩文件,默认目录为当前目录//////压缩后的文件///压缩的级别///要压缩的文件或文件夹publicvoidZip(stringzipedFileName,intzipLevel,paramsstring[]fileOrDirectory){if(fileOrDirectory==null)return;elseif(fileOrDirectory.Length<1)return;else{stringstr=fileOrDirectory[0];if(str.EndsWith("\\"))str=str.Substring(0,str.Length-1);str=str.Substring(0,str.LastIndexOf("\\"));Zip(zipedFileName,str,zipLevel,fileOrDirectory);}}//////压缩文件//////压缩后的文件///压缩的级别///当前所处目录///要压缩的文件或文件夹publicvoidZip(stringzipedFileName,stringcurrentDire
1