av激情亚洲男人的天堂国语,日韩欧美精品一中文字幕,无码av一区二区三区无码,国产又色又爽又刺激的a片,国产又色又爽又刺激的a片

VB.NET壓縮ZIP文件實際方式解析

VB.NET這樣一款面向?qū)ο蟮木幊陶Z言,應(yīng)用范圍非常廣泛,可以幫助開發(fā)人員打造一個穩(wěn)定安全的開發(fā)框架。而且其對文件的處理方面也是非常強大的。這里就為大家介紹一下有關(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)代碼編寫方式就為大家介紹到這里。


當(dāng)前題目:VB.NET壓縮ZIP文件實際方式解析
本文路徑:http://uogjgqi.cn/article/dhipods.html
掃二維碼與項目經(jīng)理溝通

我們在微信上24小時期待你的聲音

解答本文疑問/技術(shù)咨詢/運營咨詢/技術(shù)建議/互聯(lián)網(wǎng)交流