Foxtable(狐表)用户栏目专家坐堂 → 在ft中如何改写这段代码?


  共有1586人关注过本帖树形打印复制链接

主题:在ft中如何改写这段代码?

帅哥哟,离线,有人找我吗?
kgdce
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:620 积分:6782 威望:0 精华:0 注册:2013/12/17 1:00:00
在ft中如何改写这段代码?  发帖心情 Post By:2023/3/24 17:42:00 [只看该作者]

C#(VB.NET) 压缩成zip包  

SharpZipLib第三方插件(开源免费)

Private Sub fileToZip(ByVal sourceDir As String, ByVal targetName As String)
'sourceDir="D:\test" 被压缩的文件夹路径。
If sourceDir.Length = 0 Then
    MessageBox.Show("Please specify a directory")
    Return
Else
    If Not Directory.Exists(sourceDir) Then
MessageBox.Show(sourceDir, "Directory not found")
Return
    End If
End If
 
'targetName="D:\test\A.zip"指定压缩后的路径和文件夹。
If targetName.Length = 0 Then
    MessageBox.Show("No name specified", "Zip file name error")
    Return
End If
 
Dim astrFileNames() As String = Directory.GetFiles(sourceDir)
Dim strmZipOutputStream As ZipOutputStream
 
strmZipOutputStream = New ZipOutputStream(File.Create(targetName))
Try
 
    REM Compression Level: 0-9
    REM 0: no(Compression)
    REM 9: maximum compression
    strmZipOutputStream.SetLevel(9)
 
    Dim strFile As String
    Dim abyBuffer(4096) As Byte
 
    For Each strFile In astrFileNames
Dim strmFile As FileStream = File.OpenRead(strFile)
Try
 
    Dim objZipEntry As ZipEntry = New ZipEntry(Path.GetFileName(strFile))
    objZipEntry.DateTime = DateTime.Now
    objZipEntry.Size = strmFile.Length
 
    strmZipOutputStream.PutNextEntry(objZipEntry)
    StreamUtils.Copy(strmFile, strmZipOutputStream, abyBuffer)  黄色的不知道如何改写,请帮助!
Finally
    strmFile.Close()
End Try
    Next
 
    strmZipOutputStream.Finish()
Finally
    strmZipOutputStream.Close()
End Try
End Sub

 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:106680 积分:542589 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2023/3/25 8:54:00 [只看该作者]

看源码,写全命名空间即可

ICSharpCode.SharpZipLib.Core.StreamUtils.Copy(...........

 回到顶部