成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

闡述VS2003壓縮代碼的有關常識

開發 后端
我們經常會遇到編制VS2003壓縮代碼的問題,也會遇到將VS2003壓縮代碼修改的的問題。那么,如何解決此類問題呢?下文就給大家進行全面的講解。

昨天到今天搞了一整天的VS2003壓縮代碼,我都快崩潰了! 一看到那些代碼,腦袋頓時就像爆炸一樣,所以有了許多的問題出現,還好,我一個個把他記錄下來了,同時,在相關論壇上找了一些相關的解決辦法,分享一下,供大家相互學習交流

1、首先從這里下載0.84版本的VS2003壓縮代碼及示例碼。

2、下載下來之后你發現它沒有VS2003的解決方案文件,沒有關系。你可以自己建立,首先新建一個ZipUnzip的解決方案,然后,將上面經過解壓縮之后的所有文件及目錄COPY到你的解決方案所在的目錄下。 #t#

3、在VS2003解決方案資源管理器(一般是在右上方中部點的位置)中點擊顯示所有文件按鈕,然后可以見到很多“虛”的圖標、文件及文件夾等,可以一次選擇它們,然后包含進項目中。

4、編譯,***使用Release選項,編譯完成之后你可以在\bin\Release\看到ZipUnzip.dll的類了。如果你編譯時報錯,說什么AssemblyKeyFile之類的,你可以使用強命名工具新建一個,也可以將AssemblyInfo.cs中[assembly: AssemblyKeyFile("。。。。。")]改成:[assembly: AssemblyKeyFile("")] (不推薦這樣做)。

5、新建一個WEBFORM項目,添加ZipUnzip.dll類的引用,然后添加如下文件及內容:

  1. using System;  
  2. using System.IO;  
  3. using ICSharpCode.SharpZipLib.Zip;  
  4. using ICSharpCode.SharpZipLib.GZip;  
  5. using ICSharpCode.SharpZipLib.BZip2;  
  6. using ICSharpCode.SharpZipLib.Checksums;  
  7. using ICSharpCode.SharpZipLib.Zip.Compression;  
  8. using ICSharpCode.SharpZipLib.Zip.Compression.Streams;  
  9.  
  10. namespace WebZipUnzip  
  11. {  
  12.  public class AttachmentUnZip  
  13.  {  
  14. public AttachmentUnZip()  
  15. {}  
  16. public static void UpZip(string zipFile)  
  17. {  
  18. string []FileProperties=new string[2];  
  19. FileProperties[0]=zipFile;//待解壓的文件  
  20. FileProperties[1]=zipFile.Substring(0,zipFile.LastIndexOf("\\")+1);//解壓后放置的目標目錄  
  21. UnZipClass UnZc=new UnZipClass();  
  22. UnZc.UnZip(FileProperties);  
  23. }  
  24.  }  
  25. }  
  26.  
  27. // ---------------------------------------------  
  28. // 2. UnZipClass.cs  
  29. // ---------------------------------------------  
  30.  
  31. using System;  
  32. using System.IO;  
  33. using ICSharpCode.SharpZipLib.Zip;  
  34. using ICSharpCode.SharpZipLib.GZip;  
  35. using ICSharpCode.SharpZipLib.BZip2;  
  36. using ICSharpCode.SharpZipLib.Checksums;  
  37. using ICSharpCode.SharpZipLib.Zip.Compression;  
  38. using ICSharpCode.SharpZipLib.Zip.Compression.Streams;  
  39.  
  40. namespace WebZipUnzip  
  41. {  
  42.  public class UnZipClass  
  43.  {   
  44. ///   
  45. /// 解壓文件  
  46. ///   
  47. /// 包含要解壓的文件名和要解壓到的目錄名數組  
  48. public void UnZip(string[] args)  
  49. {  
  50. ZipInputStream s = new ZipInputStream(File.OpenRead(args[0]));  
  51. try  
  52. {   
  53.  ZipEntry theEntry;  
  54.  while ((theEntry = s.GetNextEntry()) != null)   
  55.  {   
  56. string directoryName = Path.GetDirectoryName(args[1]);  
  57. string fileName = Path.GetFileName(theEntry.Name);  
  58.  
  59. //生成解壓目錄  
  60. Directory.CreateDirectory(directoryName);  
  61.  
  62. if (fileName != String.Empty)   
  63. {   
  64. //解壓文件到指定的目錄  
  65. FileStream streamWriter = File.Create(args[1]+fileName);  
  66. int size = 2048;  
  67. byte[] data = new byte[2048];  
  68. while (true)   
  69. {  
  70.  ssize = s.Read(data, 0, data.Length);  
  71.  if (size > 0)   
  72.  {  
  73. streamWriter.Write(data, 0, size);  
  74.  }   
  75.  else   
  76.  {  
  77. break;  
  78.  }  
  79. }  
  80. streamWriter.Close();  
  81. }  
  82.  }  
  83.  s.Close();  
  84. }  
  85. catch(Exception eu)  
  86. {  
  87.  throw eu;  
  88. }  
  89. finally  
  90. {  
  91.  s.Close();  
  92. }  
  93. }//end UnZip  
  94.  
  95. public static bool UnZipFile(string file, string dir)  
  96. {  
  97. try  
  98. {  
  99.  if (!Directory.Exists(dir))  
  100. Directory.CreateDirectory(dir);  
  101. string fileFullName = Path.Combine(dir,file);  
  102. ZipInputStream s = new ZipInputStream(File.OpenRead( fileFullName ));  
  103.    
  104. ZipEntry theEntry;  
  105. while ((theEntry = s.GetNextEntry()) != null)  
  106. {  
  107. string directoryName = Path.GetDirectoryName(theEntry.Name);  
  108. string fileName = Path.GetFileName(theEntry.Name);  
  109.    
  110. if (directoryName != String.Empty)  
  111.  Directory.CreateDirectory( Path.Combine(dir, directoryName));  
  112.  if (fileName != String.Empty)  
  113.  {  
  114. FileStream streamWriter = File.Create( Path.Combine(dir,theEntry.Name) );  
  115. int size = 2048;  
  116. byte[] data = new byte[2048];  
  117. while (true)  
  118. {  
  119. ssize = s.Read(data, 0, data.Length);  
  120. if (size > 0)  
  121. {  
  122.  streamWriter.Write(data, 0, size);  
  123. }  
  124. else  
  125. {  
  126.  break;  
  127. }  
  128. }  
  129. streamWriter.Close();  
  130.  }  
  131. }  
  132. s.Close();  
  133. return true;  
  134. }  
  135. catch (Exception)  
  136. {  
  137. throw;  
  138. }  
  139.  }  
  140. }//end UnZipClass  

此方案解決了文件名中文字的問題,目錄VS2003壓縮代碼問題,至于整個文件夾批量上傳并壓縮成一個WINZIP壓縮包的問題,沒有時間解決了,各位如有解決方案,不妨共享一下。

責任編輯:chenqingxiang 來源: 計世網
相關推薦

2009-11-26 17:02:29

VS2003配置

2009-12-01 14:30:08

VS2003使用

2009-11-30 09:27:38

VS2003源代碼

2009-11-30 09:16:44

VS2003源代碼

2009-11-25 10:14:43

2009-12-15 13:39:43

2009-11-27 08:59:29

VS2003配置文件

2009-12-18 10:10:49

VS 2003程序

2009-12-09 13:41:04

VS 2003 報錯

2009-11-30 13:51:28

2009-11-26 13:55:35

VS2003源代碼

2009-12-09 16:52:51

VS 2003插件

2009-11-30 15:57:18

VS2003 MFC

2009-11-30 11:05:19

VS2003 WebS

2009-11-30 16:50:26

VS2003調試

2009-11-30 17:28:39

VS2003 ASP

2009-12-01 10:54:48

VS2003 英文版

2009-12-01 15:32:48

VS2003配置

2009-11-25 13:57:25

VS2003發布

2009-11-26 10:02:06

點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 欧美福利| 拍真实国产伦偷精品 | 一级片在线观看 | 涩在线| 国产一区二区三区日韩 | 我想看一级黄色毛片 | 免费成人高清 | 国产在线高清 | 91看片视频| 爱爱免费视频 | 欧美a级成人淫片免费看 | 日本精品一区二区 | 久久国内精品 | 久久激情网 | 国产精品美女www爽爽爽 | 天天操网 | 午夜丰满少妇一级毛片 | 日本亚洲欧美 | 久久青青 | 在线播放精品视频 | 拍真实国产伦偷精品 | 91大片| 韩国av电影网 | 国产精品一区二区三区久久 | 一级免费在线视频 | 欧美a级成人淫片免费看 | 亚洲91 | 国产精品视频播放 | 欧美日韩久久久久 | 欧美在线视频一区二区 | japanhd成人| 色噜噜狠狠色综合中国 | 精品久久久久久久人人人人传媒 | 国产成人综合在线 | 欧美精品v国产精品v日韩精品 | 在线观看亚洲精品视频 | 日韩精品一区在线 | 国产激情偷乱视频一区二区三区 | 国内自拍第一页 | 成人深夜小视频 | 亚洲欧美激情国产综合久久久 |