日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

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

新聞中心

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

VB.NET這樣一款面向?qū)ο蟮木幊陶Z言,應(yīng)用范圍非常廣泛,可以幫助開發(fā)人員打造一個穩(wěn)定安全的開發(fā)框架。而且其對文件的處理方面也是非常強(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. '---使用存儲在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. '---用來存儲解壓的數(shù)據(jù)---  
  16. Dim dc_data() As Byte  
  17. '---解壓的數(shù)據(jù)存儲于zipStream中;   
  18. '把它們提取到一個字節(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. '---從一個流對象中檢索字節(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)代碼編寫方式就為大家介紹到這里。


網(wǎng)頁標(biāo)題:VB.NET壓縮ZIP文件實(shí)際方式解析
文章源于:http://www.5511xx.com/article/dhipods.html