I would like to do the following all in memory without writing to disk on the client's machine.
Zip an in-memory DataTable in .NET 2.0 (C#) to memory (not disk). Then I'll send it ( string/byte/stream .. whatever it's called) to our web service.
I found some code to change the DataTable into a stream, so I think that's the first part. thanks!
You can use a MemoryStream or a StringWriter with these overloads to keep it all in memory.
string result;
using (StringWriter sw = new StringWriter()) {
dataTable.WriteXml(sw);
result = sw.ToString();
}
If you don't actually need a string but read-only, process able XML, it's a better idea to use MemoryStream and XPathDocument:
XPathDocument result;
using (MemoryStream ms = new MemoryStream()) {
dataTable.WriteXml(ms);
ms.Position = 0;
result = new XPathDocument(ms);
}