Code:
private void ZipAndSave(DataSet ds, DataSet ds2, string Destination)
{
ZipOutputStream s = new
ZipOutputStream(File.Create(Destination));
s.SetLevel(9);
s.Password = ZPW;
ZipEntry schema = new ZipEntry("csMod.xsd");
s.PutNextEntry(schema);
ds2.WriteXmlSchema(s);
ZipEntry data = new ZipEntry("csMod.xml");
s.PutNextEntry(data);
ds.WriteXml(s);
s.Finish();
s.Close();
}
fsSend = new System.IO.FileStream(Destination,
System.IO.FileMode.Open,
System.IO.FileAccess.Read);
byte[] b = new byte[fsSend.Length];
fsSend.Read(b, 0, (int)fsSend.Length);
ProcessCXML(b);--This is a function residing on server, a remote
function...
public void ProcessCXML(byte[] bytearray)
{
MemoryStream ms = new MemoryStream();
ms.Write(bytearray, 0, bytearray.Length);
DataSet ds =
LoadDataFromFile(ms);
}
public DataSet LoadDataFromFile(MemoryStream ms)
{
Stream _trSchema = null;
DataSet ds = null;
Hashtable ht = new Hashtable();
int BUFFER_SIZE = 2048;
ZipInputStream zin = null;
zin = new ZipInputStream(ms);
zin.Password = ZPW;
if (zin != null)
{
ZipEntry entry = null;
while ((entry = zin.GetNextEntry()) != null)
{
MemoryStream stream = new MemoryStream();
int size = BUFFER_SIZE;
byte[] data = new byte[BUFFER_SIZE];
while (true)
{
size = zin.Read(data, 0, data.Length);
if (size > 0)
{
stream.Write(data, 0, size);
}
else
{
break;
}
}
stream.Position = 0;
TextReader reader = new StreamReader(stream,
Encoding.UTF8);
if (entry.Name.EndsWith(".xsd"))
{
ht.Add(entry.Name.ToLower(), stream);
}
else
{
ht.Add(entry.Name.ToLower(), reader);
}
}
}
if (ht["csmod.xml"] != null)
{
ds = new DataSet();
try
{
ds.ReadXml((TextReader)ht["csmod.xml"]);
if (ht["csmod.xsd"] != null)
{
_trSchema = (Stream)ht["csmod.xsd"];
_trSchema.Position = 0;
ds.ReadXmlSchema(_trSchema);
}
}
catch (Exception)
{
ds = null;
}
}
return ds;
}
Error in ProcessCXML: Unexpected EOF at
ICSharpCode.SharpZipLib.Zip.Compression.Streams.In flaterInputBuffer.Fill()
at
ICSharpCode.SharpZipLib.Zip.Compression.Streams.In flaterInputBuffer.ReadLeB**
yte()
at ICSharpCode.SharpZipLib.Zip.ZipInputStream.GetNext Entry()
at CSRemoteServerService.ServerImpl.LoadDataFromFile( MemoryStream
ms)
at CSRemoteServerService.ServerImpl.ProcessCXML(Byte[] bytearray)
