You can use a MemoryFile to write the table to it, and use it to copy it to a zip archive in memory, and then use this archive to send it to the Web Service, via a stream for example.
e.g.:
AbstractFile dest = new MemoryFile( "ram", "DataTable" );
dest.Create();
using( Stream destStream = dest.OpenWrite( true ) )
{
string line = "Try with this text";
System.Text.Encoding.ASCII.GetBytes( line );
byte[] buffer = System.Text.Encoding.ASCII.GetBytes( line );
destStream.Write( buffer, 0, buffer.Length );
}
AbstractFile memZip = new MemoryFile( "Ram", "archive.zip" );
ZipArchive archive = new ZipArchive( memZip );
dest.CopyTo( archive,
true );
using( Stream stream = memZip.OpenRead() )
{
//...stream it to the Web Service
}
//You can verify that it works with the code bellow
ZippedFile zippedFile = new ZippedFile( memZip, "DataTable" );
AbstractFile unzippedFile = new MemoryFile();
zippedFile.CopyTo( unzippedFile,
true );
using( Stream stream = unzippedFile.OpenRead() )
{
byte[] buffer = new byte[ stream.Length ];
stream.Read( buffer, 0, buffer.Length );
Console.WriteLine( System.Text.Encoding.ASCII.GetString( buffer ) );
}
André
Software Developer and Tech Support
Xceed Software Inc.