日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
VB.NET壓縮ZIP文件實(shí)際方式解析

VB.NET這樣一款面向?qū)ο蟮木幊陶Z(yǔ)言,應(yīng)用范圍非常廣泛,可以幫助開發(fā)人員打造一個(gè)穩(wěn)定安全的開發(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. '---開始秒表---  
  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)代碼編寫方式就為大家介紹到這里。


分享題目:VB.NET壓縮ZIP文件實(shí)際方式解析
URL地址:http://www.dlmjj.cn/article/dhipods.html