I was trying to unzip a file into the memory stream instead of writing it to text file. The problem I am facing is, the 13 characters in the file's first line are missing other than that everything is fine.
Please suggest any ideas!!!!!
I have tried setting the SeekOrigin to Begin and also set the Position to 0 but of no use.
The code is pasted below,
Expand|Select|Wrap|Line Numbers
- FileStream fs = File.OpenRead(_fileName);
- using (ZipInputStream s = new ZipInputStream(fs))
- {
- ZipEntry theEntry;
- while ((theEntry = s.GetNextEntry()) != null)
- {
- int size = 2048;
- byte[] data = new byte[2048];
- MemoryStream ms = new MemoryStream(data);
- StreamWriter streamWriter = new StreamWriter(ms);
- size = s.Read(data, 0, data.Length);
- if (size > 0)
- {
- streamWriter.Write(data);
- ms.Position = 0;
- }
- else
- {
- break;
- }
- }
- }