473,508 Members | 2,216 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MemoryStream C#

2 New Member
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,
Expand|Select|Wrap|Line Numbers
  1. FileStream fs = File.OpenRead(_fileName);
  2.                 using (ZipInputStream s = new ZipInputStream(fs))
  3.                 {
  4.                     ZipEntry theEntry;
  5.                     while ((theEntry = s.GetNextEntry()) != null)
  6.                     {
  7.                             int size = 2048;
  8.                             byte[] data = new byte[2048];
  9.                             MemoryStream ms = new MemoryStream(data);
  10.                             StreamWriter streamWriter = new StreamWriter(ms);
  11.                             size = s.Read(data, 0, data.Length);
  12.                             if (size > 0)
  13.                             {
  14.                                 streamWriter.Write(data);
  15.                                 ms.Position = 0;
  16.                             }
  17.                            else
  18.                            {
  19.                                 break;
  20.                            }
  21. }
  22. }
Feb 11 '08 #1
2 2648
Shashi Sadasivan
1,435 Recognized Expert Top Contributor
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?
Feb 11 '08 #2
aa49
2 New Member
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
Feb 12 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
11121
by: xmlguy | last post by:
PREVIOUS BACKGROUND POST: I am trying to reuse a Memory Stream for loading and transforming the xml it contains Basically I have defined following interfaces: Class Render {
1
5551
by: Arcnet | last post by:
Using MemoryStream I Have a problem to create a new Image from byte array that originaly was created from an older image (Everything is being preformed in the same Thread) //Get Image...
3
10936
by: Nicolas | last post by:
Hi Everybody, I'm working with the MemoryStream and I'm having problems with the ReadBytes method. When I use it, this method never returns bytes!!!! MemoryStream sw = new MemoryStream();...
2
2117
by: SQLScott | last post by:
For some reason I am drawing a blank on this, so I would be extremely greatful if someone could help me out. I am trying to get a MemoryStream out of a Byte array. How do I get it back out? ...
13
2832
by: Don | last post by:
When I run the following code, the MemoryStream's Position is always set to 762 instead of 0, which is what I would expect: Dim bmp As Image Dim ms As MemoryStream bmp = New...
10
17812
by: Asaf | last post by:
Hi, I am trying to Compress & Decompress a DataSet. When running this code I am receiving the error: System.Xml.XmlException was unhandled Message="Root element is missing."...
4
8409
by: Heron | last post by:
Hi, Could someone explain me why the following code doesn't work? The memorystream always remains with length 0. MemoryStream input = new MemoryStream();
4
5642
by: | last post by:
Hi all, I want to create a method that does the following: 1) Programmatically instantiate a new XmlDataSource control 2) For each file in a named directory, make a "FileSystemItem" element 3)...
3
5525
by: =?Utf-8?B?UGhpbCBKb2huc29u?= | last post by:
Hi, I am using dotnet remoting with a binarry formatter. I have a property that returns a memorystream that has had a file loaded into it. When I try to access this property though I get an...
3
4753
by: =?Utf-8?B?VmljdG9y?= | last post by:
Hi, Could you tell me can I keep the MemoryStream open and "close" the BinaryReader? As the MemoryStream is used for buffering the TCP data and BinaryReader is only used to read the...
0
7127
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7391
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7054
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7501
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5056
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4713
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3188
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1564
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
424
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.