internal void Serialize(string filePath)
{
Stream stream = new MemoryStream();
System.Windows.Forms.Cursor cursor = System.Windows.Forms.Cursor.Current;
try
{
Serialize(stream, true);
stream.Position = 0;
byte[] buffer = new byte[8192];
if (".xml".Equals(Path.GetExtension(filePath).ToLower()))
{
#if DEBUG
FileStream fWritter = File.Create(filePath);
StreamUtils.Copy(stream, fWritter, buffer);
fWritter.Close();
#else
throw new Exception("XML format not supported by current version");
#endif
}
else
{
FileStream fs = File.Create(filePath);
BinaryFormatter bformatter = new BinaryFormatter();
bformatter.Serialize(fs, "version=7.14");
using (ZipOutputStream s = new ZipOutputStream(fs))
{
try
{
System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
s.Password = "mnloaw7ur4hlu.awdebnc7loy2hq3we89";
if (model.HasResults)
s.SetLevel(5); // 0 (store only) to 9 (best compression)
else
s.SetLevel(9); // 0 (store only) to 9 (best compression)
ZipEntry entry = new ZipEntry(Path.GetFileName("[Empty]"));
s.PutNextEntry(entry);
StreamUtils.Copy(stream, s, buffer);
}
finally
{
s.Flush();
s.Finish();
s.Close();
s.Dispose();
}
}
}
}
finally
{
stream.Close();
System.Windows.Forms.Cursor.Current = cursor;
}
}