-1

I will have directories with a number like 123456, and inside I will have one or multiple zip files with Version 1, Version 2, Version 3, etc. I will need to read from the last zip file (in this instance, Version 3), and grab some information from that file. I have that part down (i.e. if I unzip the file and read from the directory, my code reads the directory how I want it to), but I have been unable so far to read from the zip file. I don't want to actually have to extract anything if I can help it.

Dim path = "c:/MyZipFiles/"
Dim id = 123456
Dim dirInfo = New DirectoryInfo(String.Format("{0}{1}", path, id))
If IO.Directory.Exists(path) Then
    Dim dirList = dirInfo.GetDirectories("Version *.zip", SearchOption.TopDirectoryOnly)
    For Each dirInfo In dirList
         ' read the zip file from here - do I need a using statement?
    Next
End If 
mydisplay
  • 9
  • 2

1 Answers1

0

You can use the ZipFile.OpenRead method (documentation) to return a ZipArchive. From here you can either get everything or a single file by accessing the Entries (documentation) or GetEntry (documentation) methods.

Here is an example that would go in your For/Each loop:

Using archive = ZipFile.OpenRead(dirInfo)
    For Each entry = archive.Entries()
        Console.WriteLine(entry.FullName)
    Next
End Using
David
  • 5,877
  • 3
  • 23
  • 40