广告广告
  加入我的最爱 设为首页 风格修改
首页 首尾
 手机版   订阅   地图  繁体 
您是第 4842 个阅读者
 
发表文章 发表投票 回覆文章
  可列印版   加为IE收藏   收藏主题   上一主题 | 下一主题   
vsqa
数位造型
个人文章 个人相簿 个人日记 个人地图
路人甲
级别: 路人甲 该用户目前不上站
推文 x0 鲜花 x1
分享: 转寄此文章 Facebook Plurk Twitter 复制连结到剪贴簿 转换为繁体 转换为简体 载入图片
推文 x0
[.Net][教学] GZipStream 压缩、解压缩
VB.net 2005内GZipStream类别可以针对档案做压缩、解压缩

Imports System.IO
Imports System.IO.Compression

Public Class ClsZip
Public Sub CompressFile(ByVal sourceFile As String, ByVal destinationFile As String)
'压缩档案
If Not File.Exists(sourceFile) Then
Throw New FileNotFoundException
End If

Dim sourceStream As FileStream = Nothing
Dim destinationStream As FileStream = Nothing
Dim compressedStream As GZipStream = Nothing

Try
'Read the bytes from the source file into a byte array
sourceStream = New FileStream(sourceFile, FileMode.Open, FileAccess.Read, FileShare.Read)
'Read the source stream values into the buffer
Dim buffer(sourceStream.Length - 1) As Byte
Dim checkCounter As Integer = sourceStream.Read(buffer, 0, buffer.Length)

If checkCounter <> buffer.Length Then
Throw New ApplicationException
End If

'Open the FileStream to write to
destinationStream = New FileStream(destinationFile, FileMode.OpenOrCreate, FileAccess.Write)

'Create a compression stream pointing to the destiantion stream
compressedStream = New GZipStream(destinationStream, CompressionMode.Compress, True)

'Now write the compressed data to the destina ..

访客只能看到部份内容,免费 加入会员 或由脸书 Google 可以看到全部内容




献花 x0 回到顶端 [楼 主] From:欧洲 | Posted:2007-06-30 16:48 |

首页  发表文章 发表投票 回覆文章
Powered by PHPWind v1.3.6
Copyright © 2003-04 PHPWind
Processed in 0.013240 second(s),query:15 Gzip disabled
本站由 瀛睿律师事务所 担任常年法律顾问 | 免责声明 | 本网站已依台湾网站内容分级规定处理 | 连络我们 | 访客留言