Read a XML-File

Nov 5, 2011 at 10:50 PM
Edited Nov 5, 2011 at 10:53 PM

Hello,

I have an archive with a folder structure:
\folder1\subfolder1\test.txt
\folder2\subfolder1\new.txt
\folder2\subfolder2\ord.xml

Now I have to open the File new.txt.

I tried to read with the follow code, but it not works (strZipFolderFile = \folder2\subfolder1\new.txt):
Dim ZipEntryEngOut As Ionic.Zip.ZipEntry = zipFile.Item(strZipFolderFile)
Dim ZipEntryReader As New System.IO.StreamReader(ZipEntryEngOut.OpenReader(strEngPassword))

How can I read one specific file without to read all ZipEntries to find the file new.txt?

Thank you vor your help in advance.

Maximilian

Coordinator
Nov 7, 2011 at 5:11 PM

You said that your code does not work.  But you did not say how the code fails.

Also, you have not shown real code. You have shown only a few lines. 

I can try to help, but you need to (1) Show more code.  and (2) Describe the exact failure. If it is an exception, then show the exact exception.

This is what it would look like in C#, to read a single entry.

using (var zip = ZipFile.Read(pathOfExistingZip))
{
    ZipEntry e = zip["\\path.to\\file\\in\\archive.txt"];
    Stream s = e.OpenReader();
    // read stream here ...
}

I don't know exactly how to say that in VB.NET, but you should be able to figure it out.

Nov 14, 2011 at 10:07 AM

Hi Cheeso,

thanks a lot for your answer, I had have a mistake in using your dll, sorry for that.

Regards,
Maximilian