加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

在VB.net中解压缩文件

发布时间:2020-12-17 07:11:39 所属栏目:百科 来源:网络整理
导读:有人可以帮我解决如何在VB.Net中解压缩zip文件的问题吗? 即时通讯使用“Imports Shell32” 解决方法 如果您看一下这篇 CodeProject文章,它应该对您有所帮助.如果您遇到特定问题,则需要将代码和问题描述放在您的问题中. 从上面的文章: Sub UnZip() Dim sc A
有人可以帮我解决如何在VB.Net中解压缩zip文件的问题吗?

即时通讯使用“Imports Shell32”

解决方法

如果您看一下这篇 CodeProject文章,它应该对您有所帮助.如果您遇到特定问题,则需要将代码和问题描述放在您的问题中.

从上面的文章:

Sub UnZip()
    Dim sc As New Shell32.Shell()
    'Create directory in which you will unzip your files .
    IO.Directory.CreateDirectory("D:extractedFiles") 
    'Declare the folder where the files will be extracted
    Dim output As Shell32.Folder = sc.NameSpace("D:extractedFiles")
    'Declare your input zip file as folder  .
    Dim input As Shell32.Folder = sc.NameSpace("d:myzip.zip")
    'Extract the files from the zip file using the CopyHere command .
    output.CopyHere(input.Items,4)

End Sub

链接Folder.CopyHere方法

或者,如果您使用的是.Net 4.5,则可以使用ZipFile Class

链接示例:

Imports System.IO
Imports System.IO.Compression

Module Module1

    Sub Main()
        Dim startPath As String = "c:examplestart" 
        Dim zipPath As String = "c:exampleresult.zip" 
        Dim extractPath As String = "c:exampleextract"

        ZipFile.CreateFromDirectory(startPath,zipPath)

        ZipFile.ExtractToDirectory(zipPath,extractPath)
    End Sub 

End Module

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读