Share vb.net 7zip example

honglam946

New member
mã vb.net để trích xuất các tệp từ kho lưu trữ 7ZIP

`` `VBNet
Nhập khẩu Sevenzip.compression.lzma
Nhập khẩu Sevenzip.compression.Rangecoder

Chương trình lớp công khai

Công khai chia sẻ sub main ()
'Tạo một đối tượng lưu trữ 7ZIP mới.
Lưu trữ Dim dưới dạng Sevenzip.Archive () mới ()

'Mở tệp lưu trữ.
Archive.open ("C: \ Temp \ myarchive.7z")

'Nhận danh sách các tệp trong kho lưu trữ.
Các tệp Dim dưới dạng Sevenzip.Archive.File [] = Archive.files

'Vòng lặp qua các tập tin và trích xuất chúng.
Đối với mỗi tệp là Sevenzip.Archive.File trong các tệp
'Tạo một tệp đầu ra mới.
Dim OutputFile dưới dạng IO.FileStream mới (file.name, io.filemode.create)

'Trích xuất tệp từ kho lưu trữ.
Archive.extract (Tệp, OutputFile)

'Đóng tệp đầu ra.
outputfile.close ()
Kết thúc cho

'Đóng kho lưu trữ.
Lưu trữ.Close ()
Kết thúc phụ

Kết thúc lớp học
`` `

# vb.net
# 7zip
# lưu trữ
# nén
# khai thác
=======================================
of VB.NET code to extract files from a 7zip archive

```vbnet
Imports SevenZip.Compression.LZMA
Imports SevenZip.Compression.RangeCoder

Public Class Program

Public Shared Sub Main()
' Create a new 7zip archive object.
Dim archive As New SevenZip.Archive()

' Open the archive file.
archive.Open("C:\Temp\myarchive.7z")

' Get the list of files in the archive.
Dim files As SevenZip.Archive.File[] = archive.Files

' Loop through the files and extract them.
For Each file As SevenZip.Archive.File In files
' Create a new output file.
Dim outputFile As New IO.FileStream(file.Name, IO.FileMode.Create)

' Extract the file from the archive.
archive.Extract(file, outputFile)

' Close the output file.
outputFile.Close()
End For

' Close the archive.
archive.Close()
End Sub

End Class
```

# vb.net
# 7zip
# archive
# compression
# extraction
 
Join Telegram ToolsKiemTrieuDoGroup
Back
Top