国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發(fā)設計 > 正文

zip(ICSharpCode.SharpZipLib.dll文件需要下載)

2019-11-14 16:08:26
字體:
來源:轉載
供稿:網(wǎng)友
ZipClass zc=new ZipClass ();zc.ZipDir(@"E:/1/新建文件夾", @"E:/1/新建文件夾.zip", 1);//壓縮zc.UnZip(@"E:/1/新建文件夾.zip",@"E:/1/2222");//解壓

  cs

 1 class ZipClass 2 { 3 public void UnZip(string zipFilePath, string unZipDir) 4 { 5 if (zipFilePath == string.Empty) 6 { 7 throw new Exception("壓縮文件不能為空!"); 8 } 9 if (!File.Exists(zipFilePath))10 {11 throw new System.IO.FileNotFoundException("壓縮文件不存在!");12 }13 //解壓文件夾為空時默認與壓縮文件同一級目錄下,跟壓縮文件同名的文件夾 14 if (unZipDir == string.Empty)15 unZipDir = zipFilePath.Replace(Path.GetFileName(zipFilePath), Path.GetFileNameWithoutExtension(zipFilePath));16 if (!unZipDir.EndsWith("//"))17 unZipDir += "//";18 if (!Directory.Exists(unZipDir))19 Directory.CreateDirectory(unZipDir);20 21 using (ZipInputStream s = new ZipInputStream(File.OpenRead(zipFilePath)))22 {23 24 ZipEntry theEntry;25 while ((theEntry = s.GetNextEntry()) != null)26 {27 string directoryName = Path.GetDirectoryName(theEntry.Name);28 string fileName = Path.GetFileName(theEntry.Name);29 if (directoryName.Length > 0)30 {31 Directory.CreateDirectory(unZipDir + directoryName);32 }33 if (!directoryName.EndsWith("//"))34 directoryName += "//";35 if (fileName != String.Empty)36 {37 using (FileStream streamWriter = File.Create(unZipDir + theEntry.Name))38 {39 40 int size = 2048;41 byte[] data = new byte[2048];42 while (true)43 {44 size = s.Read(data, 0, data.Length);45 if (size > 0)46 {47 streamWriter.Write(data, 0, size);48 }49 else50 {51 break;52 }53 }54 }55 }56 }57 }58 }59 60  61 62 public static void ZipDir(string sDir, string sZip, ZipOutputStream s)63 {64 string[] filenames = Directory.GetFiles(sDir);65 string[] dirnames = Directory.GetDirectories(sDir);66 Crc32 crc = new Crc32();67 if (s == null)68 {69 s = new ZipOutputStream(File.Create(sZip));70 s.SetLevel(6); // 0 - store only to 9 - means best comPRession71 }72 73 74 foreach (string file in filenames)75 fileZipInStream(file, s);76 77 foreach (string dir in dirnames)78 ZipDir(dir, "", s);79 if (sZip != "")80 {81 s.Finish();82 s.Close();83 84 FileInfo fInfo = new FileInfo(sZip);85 long size = fInfo.Length;86 //Log.WriteLogD("----------------" + size.ToString());87 if (size < 100) 88 File.Delete(sZip);89 }90 }91 92 }
View Code

ICSharpCode.SharpZipLib.dll下載地址:http://i.VEVb.com/Files.aspx

感謝提供此類的朋友


發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 两当县| 靖边县| 金堂县| 体育| 健康| 瑞丽市| 十堰市| 苏尼特右旗| 靖西县| 尚志市| 富锦市| 内黄县| 肇庆市| 额济纳旗| 乌兰县| 革吉县| 潍坊市| 榆中县| 南丰县| 莫力| 鄱阳县| 聊城市| 奉新县| 九江县| 潜江市| 嘉义市| 清水河县| 牡丹江市| 仁布县| 姜堰市| 五常市| 楚雄市| 襄城县| 呼伦贝尔市| 浪卡子县| 周口市| 昌都县| 乌海市| 辽宁省| 固镇县| 穆棱市|