![]() |
| ||
| Parsing Zip Files VB.Net Hows it going everyone. Right now I am working on a project with VS2008 that parses directory and subdirectories and lists all filenames/paths/size/etc. This is working correctly, but I also need to parse the contents of zip files without actually unzipping them. What would be the easiest method to return the information on the files in a zip file? (Filename, Size, etc). Heres the code that I currently have to parse directories and subdirectories. Sub Parse(ByVal ThisFolder As String) |
| ||
| Re: Parsing Zip Files VB.Net |
| ||
| Re: Parsing Zip Files VB.Net Is this library able to just list the files? I was reading over it and mostly only saw that it zipped and unzipped files, etc. |
| ||
| Re: Parsing Zip Files VB.Net bump |
| ||
| Re: Parsing Zip Files VB.Net Can anyone help me convert this VB6 code to get zip filenames to .Net? Option Explicit |
| ||
| Re: Parsing Zip Files VB.Net Dont know if it worked but I had a go. THis is pretty much the same code in vb.net without errors. Public Class Form1 Private Const strStartPath As String = "C:\" Private Const strDestFile As String = "c:\output.txt" Private Const strDestTargetFile As String = "c:\outputTarget.txt" Private dicList As Object Private objFSO As Object Private strZipFile As String Private Sub doit() dicList = CreateObject("Scripting.Dictionary") dicList.Add(LCase("mp3"), "") dicList.Add(LCase("avi"), "") dicList.Add(LCase("wav"), "") Dim strTempFolder As String, objDestFile As Object, objDestTargetFile As Object objFSO = CreateObject("Scripting.FileSystemObject") strTempFolder = CreateTempFolder() Dim strDest As String, strDestTarget As String strDest = "" strDestTarget = "" If objFSO.FileExists(strDestFile) Then objFSO.DeleteFile(strDestFile) If objFSO.FileExists(strDestTargetFile) Then objFSO.DeleteFile(strDestTargetFile) Call TraverseFolder(strStartPath, strTempFolder) If objFSO.FolderExists(strTempFolder) Then objFSO.DeleteFolder(strTempFolder) End If Dim objFolder As Object, objFile As Object objFolder = objFSO.GetFolder(strTempFolder) strDest = "The following files are found in '" & strZipFile & "':" & vbLf strDestTarget = "The following special files are found in '" & strZipFile & "':" & vbLf For Each objFile In objFolder.Files strDest = strDest & "->" & objFSO.GetFileName(objFile) & vbLf If dicList.Items.Exists(LCase(objFSO.GetExtensionName(objFile))) Then strDestTarget = strDestTarget & "->" & objFSO.GetFileName(objFile) & vbLf End If objFSO.DeleteFile(objFile) Next objDestFile = objFSO.OpenTextFile(strDestFile, 8, True) objDestFile.Write(strDest) objDestFile.Close() objDestTargetFile = objFSO.OpenTextFile(strDestTargetFile, 8, True) objDestTargetFile.Write(strDestTarget) objDestTargetFile.Close() End Sub Function CreateTempFolder() As Object Dim objFSO As Object, strTempFile As String objFSO = CreateObject("Scripting.FileSystemObject") strTempFile = objFSO.GetTempName strTempFile = Replace(strTempFile, "." & objFSO.GetExtensionName(strTempFile), "") Dim objShell As Object objShell = CreateObject("WScript.Shell") CreateTempFolder = Replace(objShell.SpecialFolders("Desktop"), "Desktop", "Local Settings\Temp") & "\" & strTempFile ' Return Nothing End Function Private Sub TraverseFolder(ByVal strFolderPath As String, ByVal strtempfolder As String) Dim objCurrentFolder As Object, objFile As Object, objFolder As Object objCurrentFolder = objFSO.GetFolder(strFolderPath) On Error Resume Next For Each objFile In objCurrentFolder.Files If LCase(objFSO.GetExtensionName(objFile)) = "zip" Then Call UnZipAndCheckExtension(objFile, strtempfolder) End If Next For Each objFolder In objCurrentFolder.subFolders Call TraverseFolder(objFolder.ParentFolder & "\" & objFolder.name, strtempfolder) Next End Sub Function UnZipAndCheckExtension(ByVal strZipFile As String, ByVal strTempFolder As String) As Object Const strUNZIPSource As String = "WZUNZIP.EXE" Dim objFSO As Object, objShell As Object, intRet As Integer objFSO = CreateObject("Scripting.FileSystemObject") If Not objFSO.FolderExists(strTempFolder) Then objFSO.CreateFolder(strTempFolder) objShell = CreateObject("WScript.shell") On Error Resume Next intRet = objShell.Run("""" & strUNZIPSource & """ -o """ & strZipFile & """ """ & strTempFolder & """", 0, True) End If Return Nothing End Function End Class |
| ||
| Re: Parsing Zip Files VB.Net Hmm, getting a directory not found error when it gets here: objFolder = objFSO.GetFolder(strTempFolder) |
| All times are GMT -4. The time now is 5:15 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC