473,320 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

problem with compression in .NET 2.0

6
I eventually want to convert a dataset to XML, compress the XML then save to a file and be able to load this dataset back from the file. To get there I am working on figuring out the new deflatestream. I have the code below that should send the dataset to XML, compress, decompress, then turn back to dataset...but it is losing the end of the XML document. When I hit the ReadXML line I get the error that there is a missing end element in the XML. Anyone see what I'm doing wrong? Any suggestions will be greatly appreciated!

Expand|Select|Wrap|Line Numbers
  1. <code to fill the dataset ds>
  2.  
  3. MemoryStream xmlstream = new MemoryStream();
  4. DeflateStream DefStream = new DeflateStream(xmlstream, CompressionMode.Compress, false);
  5. ds.WriteXml(DefStream, XmlWriteMode.WriteSchema);
  6.  
  7. xmlstream.Seek(0, SeekOrigin.Begin);
  8. ds = new DataSet();
  9.  
  10. DeflateStream deDefStream = new DeflateStream(xmlstream, CompressionMode.Decompress, false);
  11. ds.ReadXml(deDefStream, XmlReadMode.ReadSchema);
  12.  
Dec 20 '06 #1
2 1144
Yonger
6
I'm not sure why my code above does not work...but this code is doing the job just fine. So...don't need help with this anymore, but if anyone can explain what I fixed I'd love to know :)

Expand|Select|Wrap|Line Numbers
  1. FileStream writedat = new FileStream("C:\\data\\file.dat", FileMode.Create);
  2. DeflateStream DefStream = new DeflateStream(writedat,CompressionMode.Compress, false);
  3. ds.WriteXml(DefStream, XmlWriteMode.WriteSchema);
  4. DefStream.Close();
  5. writedat.Close();
  6.  
  7. ds = new DataSet();
  8.  
  9. FileStream readdat = new FileStream("C:\\data\\file.dat", FileMode.Open);
  10. DeflateStream deDefStream = new DeflateStream(readdat, CompressionMode.Decompress, false);
  11. ds.ReadXml(deDefStream);
  12. deDefStream.Close();
  13. readdat.Close();
  14.  
Dec 20 '06 #2
bplacker
121 100+
the only thing I can think of is the line

xmlstream.Seek(0, SeekOrigin.Begin);

something about this is chopping off a tag or a character or somethin like that.
Dec 20 '06 #3

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

Similar topics

0
by: mchl gdbt | last post by:
Hi, I have several thousand tiffs generated by application A which are read by application B. I need to remove a few colours from the tiffs and I decided to try with the python imaging library....
2
by: Jim Hubbard | last post by:
I went to the compression newsgroups, but all I saw was spam. So, I thought I'd post his question here to get the best info I could from other programmers. Which compression algorithm offers...
25
by: Xah Lee | last post by:
Python Doc Problem Example: gzip Xah Lee, 20050831 Today i need to use Python to compress/decompress gzip files. Since i've read the official Python tutorial 8 months ago, have spent 30...
8
by: Anurag | last post by:
Hi, I am told that Oracle has this "data compression" feature that allows you to store online data ina compressed format. This is different from archived data - you compress only that data which...
1
by: chris.atlee | last post by:
I'm writing a program in python that creates tar files of a certain maximum size (to fit onto CD/DVD). One of the problems I'm running into is that when using compression, it's pretty much...
6
by: cyusman | last post by:
Hi, We have just moved our application to a new webfarm server environment which utilizing hardware load balancing, SSL off-loading and HTTP compression off-loading.My application is running on...
20
by: chance | last post by:
Hello, I want to add compression to a memory stream and save it in an Oracle database. This is the code I have so far: //save the Word document to a binary field, MemoryStream dataStream = new...
21
by: =?Utf-8?B?VkJB?= | last post by:
I compressed a file with GZipStream class and is larger than the original file.... how can this be?, the original file is 737 KB and the "compressed" file is 1.1 MB. Did i miss something or is...
10
by: oktayarslan | last post by:
Hi all; I have a problem when inserting an element to a vector. All I want is reading some data from a file and putting them into a vector. But the program is crashing after pushing a data which...
3
by: GiJeet | last post by:
Hello, we have an app that scans documents into TIFF format and we need to transfer them over the internet. If anyone knows of a SDK we can use that can compress TIFFs on the fly or even if it can...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.