SharpDevelop Community

Get your problems solved!
Welcome to SharpDevelop Community Sign in | Join | Help
in Search

Fastes way to read a special txt file out of a zip archive

Last post 11-19-2007 8:13 PM by JohnReilly. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 11-15-2007 3:12 PM

    • macap
    • Top 500 Contributor
    • Joined on 11-15-2007
    • Posts 9

    Fastes way to read a special txt file out of a zip archive

    Hello,

    I am searching for the fastest (best coded way) to read a specific txt file out of a zip archive. I only need the second line of this txt file,

    so I do not need to unzip and store it somewhere on the file system. How can I do this with a good coding style?

    At the moment I am iterating through the file zip file with:

    using (ZipInputStream zis = new ZipInputStream(file.InputStream))

    {

    ZipEntry theEntry; 

    while ((theEntry = zis.GetNextEntry()) != null)

    {

    if (theEntry.Name.Equals(projectName+"/Device/setup.mcl"))

    {

     //.....

    }

     

    I have read, that there is a better solution using the ZipFile class insteard, but I did not solve the problem until now.

     

    Can anybody give me a hint?

     


    Regards,

    Martin

  • 11-19-2007 8:13 PM In reply to

    Re: Fastes way to read a special txt file out of a zip archive

     Hi,

    Fastest isnt a well defined thing in that empirical research is the only real way to prove fastest.  It depends a lot on the data you are getting and the environment its all happening in.

    The ZipFile class will probably find entries faster on average if the zipfiles contain many entries and they are in random order.  You can use FindEntry to do this.

    GetInputStream can then get you the uncompressed data as a stream to read.

    hth, -jr- 

Page 1 of 1 (2 items)
Powered by Community Server (Commercial Edition), by Telligent Systems
Don't contact us via this (fleischfalle@alphasierrapapa.com) email address.