This is a migrated thread and some comments may be shown as answers.
Unzipping textfile, first character missing
3 Answers 37 Views
This is a migrated thread and some comments may be shown as answers.
roger
Top achievements
Rank 1
roger asked on 20 Jul 2011, 10:18 PM
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!

3 Answers, 1 is accepted

Sort by
0
Accepted
Viktor Tsvetkov
Telerik team
answered on 21 Jul 2011, 08:57 AM
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!

0
roger
Top achievements
Rank 1
answered on 21 Jul 2011, 09:49 AM
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!
0
Petar Mladenov
Telerik team
answered on 25 Jul 2011, 09:40 AM
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!

Asked by
roger
Top achievements
Rank 1
Answers by
Viktor Tsvetkov
Telerik team
roger
Top achievements
Rank 1
Petar Mladenov
Telerik team
Share this question
or