自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

VB.NET壓縮ZIP文件實(shí)際方式解析

開(kāi)發(fā) 后端
我們可以通過(guò)今天為大家介紹的這段代碼示例來(lái)對(duì)VB.NET壓縮ZIP文件這一應(yīng)用技巧進(jìn)行一個(gè)詳細(xì)的解讀,并對(duì)VB.NET有一個(gè)新的認(rèn)識(shí)。

VB.NET這樣一款面向?qū)ο蟮木幊陶Z(yǔ)言,應(yīng)用范圍非常廣泛,可以幫助開(kāi)發(fā)人員打造一個(gè)穩(wěn)定安全的開(kāi)發(fā)框架。而且其對(duì)文件的處理方面也是非常強(qiáng)大的。這里就為大家介紹一下有關(guān)VB.NET壓縮ZIP文件的相關(guān)方法。#t#

VB.NET壓縮ZIP文件代碼示例:

  1. Public Function Decompress()
    Function Decompress
    (ByVal algo As String, ByVal 
    data() As Byte) As Byte()  
  2. Try  
  3. Dim sw As New Stopwatch  
  4. '---復(fù)制數(shù)據(jù)(壓縮的)到ms---  
  5. Dim ms As New MemoryStream(data)  
  6. Dim zipStream As Stream = Nothing 
  7. '---開(kāi)始秒表---  
  8. sw.Start()  
  9. '---使用存儲(chǔ)在ms中的數(shù)據(jù)解壓---  
  10. If algo = "Gzip" Then  
  11. zipStream = New GZipStream(ms, 
    CompressionMode.Decompress)  
  12. ElseIf algo = "Deflate" Then  
  13. zipStream = New DeflateStream(ms, 
    CompressionMode.Decompress, True)  
  14. End If  
  15. '---用來(lái)存儲(chǔ)解壓的數(shù)據(jù)---  
  16. Dim dc_data() As Byte  
  17. '---解壓的數(shù)據(jù)存儲(chǔ)于zipStream中;   
  18. '把它們提取到一個(gè)字節(jié)數(shù)組中---  
  19. dc_data = RetrieveBytesFromStream
    (zipStream, data.Length)  
  20. '---停止秒表---  
  21. sw.Stop()  
  22. lblMessage.Text = "Decompression 
    completed. Time spent: "
     & sw.
    ElapsedMilliseconds & "ms" & _  
  23. ", Original size: " & dc_data.Length  
  24. Return dc_data  
  25. Catch ex As Exception  
  26. MsgBox(ex.ToString)  
  27. Return Nothing  
  28. End Try  
  29. End Function  
  30. Public Function RetrieveBytes
    FromStream()Function Retrieve
    BytesFromStream( _  
  31. ByVal stream As Stream, ByVal 
    bytesblock As Integer) As Byte()  
  32. '---從一個(gè)流對(duì)象中檢索字節(jié)---  
  33. Dim data() As Byte  
  34. Dim totalCount As Integer = 0 
  35. Try  
  36. While True  
  37. '---逐漸地增加數(shù)據(jù)字節(jié)數(shù)組-的大小--  
  38. ReDim Preserve data(totalCount 
    + bytesblock)  
  39. Dim bytesRead As Integer = 
    stream.Read(data, totalCount, bytesblock)  
  40. If bytesRead = 0 Then  
  41. Exit While  
  42. End If  
  43. totalCount += bytesRead  
  44. End While  
  45. '---確保字節(jié)數(shù)組正確包含提取的字節(jié)數(shù)---  
  46. ReDim Preserve data(totalCount - 1)  
  47. Return data  
  48. Catch ex As Exception  
  49. MsgBox(ex.ToString)  
  50. Return Nothing  
  51. End Try  
  52. End Function 

VB.NET壓縮ZIP文件的相關(guān)代碼編寫方式就為大家介紹到這里。

責(zé)任編輯:曹凱 來(lái)源: 博客園
相關(guān)推薦

2010-01-11 10:44:47

VB.NET多窗體

2010-01-07 16:16:03

VB.NET變量作用域

2010-01-11 17:40:36

VB.NET相框效果

2010-01-19 13:36:16

VB.NET可選參數(shù)

2010-01-07 17:57:22

VB.NET構(gòu)造函數(shù)

2010-01-11 11:37:08

VB.NET操作CSV

2010-01-15 15:03:23

VB.NET對(duì)象變量聲

2010-01-20 17:41:13

VB.NET標(biāo)記語(yǔ)句

2010-01-12 18:12:58

VB.NET事件

2009-10-21 09:19:40

VB.NET文件壓縮 

2009-10-09 15:59:41

VB.NET對(duì)象

2010-01-18 15:43:35

VB.NET自定義屬性

2009-11-02 11:02:58

VB.NET XML文

2010-01-14 17:41:57

VB.NET變量范圍

2010-01-21 16:37:56

VB.NET變量聲明

2009-11-02 14:48:45

VB.NET HOOK

2010-01-15 16:46:05

VB.NET集合存儲(chǔ)

2010-01-07 18:17:00

VB.NET連接SAP

2010-01-08 10:37:50

VB.NET數(shù)據(jù)庫(kù)

2010-01-07 18:22:40

VB.NET聲音播放
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)