MemoryStream C#

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • aa49
    New Member
    • Feb 2008
    • 2

    MemoryStream C#

    Hi all,

    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,
    [CODE=cpp]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(da ta);
    StreamWriter streamWriter = new StreamWriter(ms );
    size = s.Read(data, 0, data.Length);
    if (size > 0)
    {
    streamWriter.Wr ite(data);
    ms.Position = 0;
    }
    else
    {
    break;
    }
    }
    }[/CODE]
    Last edited by Shashi Sadasivan; Feb 11 '08, 10:54 PM. Reason: adding code tags
  • Shashi Sadasivan
    Recognized Expert Top Contributor
    • Aug 2007
    • 1435

    #2
    How many characters does your zipped text file contain?

    im not sure if this is right, as you are writing each line of the file into a new memory stream (which you declare again and again for each line read)

    could you confirm how large the text file is?

    Comment

    • aa49
      New Member
      • Feb 2008
      • 2

      #3
      Its a 100 mb csv file.

      Everything is fine and getting unzipped except that i dont see the first 13 chars of the first line only

      Comment

      Working...