· Devuelve información sobre archivos comprimidos (tamaño, nombre de los archivos internos, total de archivos internos..)
Código (vbnet) [Seleccionar]
#Region " SevenZipSharp FileInfo "
' [ SevenZipSharp FileInfo Function ]
'
' // By Elektro H@cker
'
' Instructions :
' 1. Add a reference to "SevenZipSharp.dll".
' 2. Add the "7z.dll" or "7z64.dll" files to the project.
' 3. Use the code below.
'
' Examples :
' MsgBox(SevenZipSharp_FileInfo("C:\Test.7z", SevenZip_Info.Format))
' For Each FileName In SevenZipSharp_FileInfo("C:\Test.zip", SevenZip_Info.Internal_Files_FileNames) : MsgBox(FileName) : Next
Imports SevenZip
Dim dll As String = "7z.dll"
Public Enum SevenZip_Info
FileName
Format
Size_In_Bytes
Internal_Files_FileNames
Total_Internal_Files
End Enum
Private Function SevenZipSharp_FileInfo(ByVal InputFile As String, ByVal Info As SevenZip_Info)
Try
' Set library path
SevenZip.SevenZipExtractor.SetLibraryPath(dll)
' Create extractor and specify the file to extract
Dim Extractor As SevenZip.SevenZipExtractor = New SevenZip.SevenZipExtractor(InputFile)
' Return info
Select Case Info
Case SevenZip_Info.FileName
Return Extractor.FileName
Case SevenZip_Info.Format
Return Extractor.Format
Case SevenZip_Info.Size_In_Bytes
Return Extractor.PackedSize
Case SevenZip_Info.Total_Internal_Files
Return Extractor.FilesCount
Case SevenZip_Info.Internal_Files_FileNames
Dim FileList As New List(Of String)
For Each Internal_File In Extractor.ArchiveFileData
FileList.Add(Internal_File.FileName)
Next
Return FileList
Case Else
Return Nothing
End Select
Extractor.Dispose()
Catch ex As Exception
' Return nothing
Throw New Exception(ex.Message)
End Try
End Function
#End Region