您的位置:首页 > 编程语言 > VB

sharpziplib是一个不错的在线压缩软软件.用VB.net简单写了个使用代码!

2005-06-14 22:27 941 查看
1Dim zipname As String = Path.Combine(Me.zipdir, (Me.txtZipFile.Text.ToString & ".zip"))
2 Dim crc1 As New Crc32
3 Dim s As ZipOutputStream = New ZipOutputStream(File.Create(zipname))
4 s.SetLevel(6)
5 Dim i As Integer
6 Dim flename As String() = {Server.MapPath("temp\index.htm"), Server.MapPath("temp\regriter.htm")}
7
8 For i = 0 To flename.Length - 1
9 Dim name As String = flename(i)
10 Dim stratem As FileStream = File.OpenRead(name)
11 Dim buffer As Byte() = New Byte(stratem.Length - 1) {}
12 stratem.Read(buffer, 0, buffer.Length)
13 Dim filename1 As String = name.Replace((Me.timpdir & "\"), "")
14 Dim entry As New ZipEntry(filename1)
15 entry.DateTime = DateTime.Now
16 entry.Size = stratem.Length
17 stratem.Close()
18 crc1.Reset()
19 crc1.Update(buffer)
20 entry.Crc = crc1.Value
21 s.PutNextEntry(entry)
22 s.Write(buffer, 0, buffer.Length)
23 Next
24 s.Finish()
25 s.Close()

1Imports System.IO
2
3Public Class utilClass util
4
5 Public Shared Function GetDirecotry()Function GetDirecotry(ByVal DirecotryName As String) As String
6 Dim dir As String = HttpContext.Current.Request.PhysicalApplicationPath
7 dir = Path.Combine(dir, DirecotryName)
8 If Directory.Exists(dir) = True Then
9 Directory.CreateDirectory(dir)
10 End If
11 Return dir
12 End Function
13
14End Class
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐