How to zip a stream

A

ad

I want to uplad a dataset to server by WebService,
But the dataset is to huge (50 fields in 50000 rows)
I want to compress it before upload,
Now my steps are
In Client
1. DataSet1.WriteXml("c:\my.xml")
2. Zip c:\my.xml to my.zip
3. Delete my.xml
4. Reade my.zip into FileSteam
5. Write the FileStream to Byte[]
6.Upload Byte[] by WebService

In Server
7. Save the Byte[] to disk files (my.zip)
8. unzip my.zip to my.xml
9. delete my.zip
10. Reade my.xml to a DataSet
11 Bulk copy Dataset to DataBase Server.

It is to tedious.
I want to change to
In Clinet
1. DataSet1.WriteXml(Stream myStream)
2. zip myStream.
3. Write myStream to Byte[]
4. Upload Byte[] by WebService

In Server
5 Write Byte[] to Stream
6. unzip Stream
7. read the stream into a DataSet
8 Bulk copy to Database Server.


But the problem is :
How to zip/unzip Stream?
or How to zip/unzip Byte[]?

How can I do that?
 
D

Daniel O'Connell [C# MVP]

ad said:
Thanks,
But how to use SharpZipLib to zip/unzip Stream?

There are two classes to do this in the ICSharpCode.SharpZIpLib.Zip
namespace: ZipInputStream and ZipOutputStream. You can write to the
ZipOutputStream to compress the output and read from the ZipInputStream.
They should both wrap other streams to make doing this easier.

The the docs should have sufficent examples to figure out how to use it from
this point.
 
A

ad

Thanks,

Could you give me an example?



William Stacey said:
You can compress/decompress on the fly with GZipStream in 2.0.

--
William Stacey [MVP]

ad said:
I want to uplad a dataset to server by WebService,
But the dataset is to huge (50 fields in 50000 rows)
I want to compress it before upload,
Now my steps are
In Client
1. DataSet1.WriteXml("c:\my.xml")
2. Zip c:\my.xml to my.zip
3. Delete my.xml
4. Reade my.zip into FileSteam
5. Write the FileStream to Byte[]
6.Upload Byte[] by WebService

In Server
7. Save the Byte[] to disk files (my.zip)
8. unzip my.zip to my.xml
9. delete my.zip
10. Reade my.xml to a DataSet
11 Bulk copy Dataset to DataBase Server.

It is to tedious.
I want to change to
In Clinet
1. DataSet1.WriteXml(Stream myStream)
2. zip myStream.
3. Write myStream to Byte[]
4. Upload Byte[] by WebService

In Server
5 Write Byte[] to Stream
6. unzip Stream
7. read the stream into a DataSet
8 Bulk copy to Database Server.


But the problem is :
How to zip/unzip Stream?
or How to zip/unzip Byte[]?

How can I do that?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top