Home Forums .NET libraries Xceed Zip & Real-Time Zip for .NET How to read the text inside a zipped text file without unzip

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #19787 |

    I need to read the text inside a zipped text file without unzip the file, is it possible?

    for example:
    testing.zip contain a testing.txt , and there is a string “abcd” inside testing.txt, how do i read the “abcd” without unzip testing.zip? i am using C#.Net 2005.

    thank you…!

    Imported from legacy forums. Posted by IsMe (had 2740 views)

    Xceed Support
    Member
    Post count: 5658

    Hi IsMe,

    All you need to do is to create an instance of a ZippedFile and call OpenRead on it. This will return a stream from which you will be able to read the content. Here’s a code snippet to do it:

    // Change the path for your zip file.
    DiskFile zipFile = new DiskFile( @”.\testing.zip” );

    // Get a reference on the file you want to read.
    ZippedFile fileToRead = new ZippedFile( zipFile, “testing.txt” );

    // Make sure the file exists before opening it for reading.
    if( fileToRead.Exists )
    {
    using( StreamReader reader = new StreamReader( fileToRead.OpenRead() ) )
    {
    // Do what you want with the reader.
    }
    }

    Hope this help!

    Imported from legacy forums. Posted by Jacques [Xceed] (had 289 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi Jacques,

    The code you gave me work! Thank you!!

    Imported from legacy forums. Posted by IsMe (had 3635 views)

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.