VB.net如何实现文件解压缩操作?
- 内容介绍
- 文章标签
- 相关推荐
本文共计314个文字,预计阅读时间需要2分钟。
有人可以帮我解决如何在VB.Net中解压zip文件的疑问吗?即时通讯使用Imports Shell32。如果您查看一下CodeProject文章,它应该对您有所帮助。如果您遇到特定问题,请将代码和问题一起提供。
有人可以帮我解决如何在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:\example\start" Dim zipPath As String = "c:\example\result.zip" Dim extractPath As String = "c:\example\extract" ZipFile.CreateFromDirectory(startPath, zipPath) ZipFile.ExtractToDirectory(zipPath, extractPath) End Sub End Module
本文共计314个文字,预计阅读时间需要2分钟。
有人可以帮我解决如何在VB.Net中解压zip文件的疑问吗?即时通讯使用Imports Shell32。如果您查看一下CodeProject文章,它应该对您有所帮助。如果您遇到特定问题,请将代码和问题一起提供。
有人可以帮我解决如何在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:\example\start" Dim zipPath As String = "c:\example\result.zip" Dim extractPath As String = "c:\example\extract" ZipFile.CreateFromDirectory(startPath, zipPath) ZipFile.ExtractToDirectory(zipPath, extractPath) End Sub End Module

