日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

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

發(fā)布時間:2023/12/9 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 zip (ICSharpCode.SharpZipLib.dll文件需要下载) 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
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 //解壓文件夾為空時默認(rèn)與壓縮文件同一級目錄下,跟壓縮文件同名的文件夾 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 else 50 { 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 compression 71 } 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.cnblogs.com/Files.aspx

感謝提供此類的朋友

轉(zhuǎn)載于:https://www.cnblogs.com/yuanjiehot/p/4320976.html

總結(jié)

以上是生活随笔為你收集整理的zip (ICSharpCode.SharpZipLib.dll文件需要下载)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。