Unzipping textfile, first character missing

4 posts, 1 answers
  1. roger
    roger avatar
    24 posts
    Member since:
    Jun 2009

    Posted 20 Jul 2011 Link to this post

    Hey guys, I got the following stored in a text (.txt) file, which is, of course, zipped:
    Hello World!

    However, if I read the file like:
    ZipInputStream zis = new ZipInputStream(entry.OpenInputStream());                             
    StreamReader streamReader = new StreamReader(zis);                             
    String text = streamReader.ReadToEnd();

    The string (text) is:
    ello World!

    Am I doing something wrong or is this a bug (a read() instead of a peek() somewhere)?

    Thank you!
  2. Answer
    Viktor Tsvetkov
    Admin
    Viktor Tsvetkov avatar
    382 posts

    Posted 21 Jul 2011 Link to this post

    Hello Roger,

    You don't need to create new ZipInputStream object, because OpenInputStream() method actually returns the decompressed stream, so you should simply pass it to the stream reader:
    StreamReader streamReader = new StreamReader(entry.OpenInputStream());
    string text = streamReader.ReadToEnd();
    If you have further questions feel free to ask.

    Greetings,
    Viktor Tsvetkov
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  3. roger
    roger avatar
    24 posts
    Member since:
    Jun 2009

    Posted 21 Jul 2011 Link to this post

    Thank you that did it. It should be documented how to open files, I couldn't find it in the help files.

    Thank you for your help!
  4. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 25 Jul 2011 Link to this post

    Hi Roger,

     We appreciate your feedback and will try to improve our documentation resources. Thank you for your cooperation.

    All the best,
    Petar Mladenov
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Back to Top