# How to serialize multiple layers in a single file

**URL:** <https://community.thinkgeo.com/t/how-to-serialize-multiple-layers-in-a-single-file/2017>\
**Category:** WinForms\
**Created:** [July 2, 2012, 9:40am UTC](https://community.thinkgeo.com/t/how-to-serialize-multiple-layers-in-a-single-file/2017 "2012-07-02T09:40:36Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Steven1](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/steven1/32/18983_2.png) [@Steven1](https://community.thinkgeo.com/u/Steven1)\
**Post date:** [July 2, 2012, 9:40am UTC](https://community.thinkgeo.com/t/how-to-serialize-multiple-layers-in-a-single-file/2017/1 "2012-07-02T09:40:36Z")

</div>

Guys,

I&nbsp;have&nbsp;been&nbsp;using&nbsp;.NET&nbsp;binary&nbsp;serialization&nbsp;to&nbsp;save/restore&nbsp;the&nbsp;state&nbsp;of&nbsp;the&nbsp;map.&nbsp;This&nbsp;approach&nbsp;works&nbsp;great&nbsp;until&nbsp;we&nbsp;download&nbsp;a&nbsp;new&nbsp;set&nbsp;of&nbsp;dll's&nbsp;from&nbsp;the&nbsp;daily&nbsp;build&nbsp;and&nbsp;some&nbsp;change&nbsp;in&nbsp;one&nbsp;of&nbsp;the&nbsp;classes&nbsp;causes&nbsp;existing&nbsp;files&nbsp;no&nbsp;longer&nbsp;to&nbsp;load&nbsp;because&nbsp;of&nbsp;compatibility&nbsp;issues&nbsp;in&nbsp;the&nbsp;newer&nbsp;version.

Since&nbsp;ThinkGeo&nbsp;has&nbsp;now&nbsp;released&nbsp;the&nbsp;GeoSerializer&nbsp;(which&nbsp;is&nbsp;supposed&nbsp;to&nbsp;solve&nbsp;the&nbsp;compatibilty&nbsp;issue)&nbsp;I&nbsp;would&nbsp;like&nbsp;to&nbsp;switch&nbsp;to&nbsp;that&nbsp;method.&nbsp;However,&nbsp;if&nbsp;I&nbsp;try&nbsp;to&nbsp;serialize&nbsp;more&nbsp;than&nbsp;one&nbsp;layer&nbsp;to&nbsp;the&nbsp;file&nbsp;I&nbsp;receive&nbsp;an&nbsp;error&nbsp;when&nbsp;trying&nbsp;to&nbsp;deserialize:

`System.Xml.XmlException was unhandled  LineNumber=122  LinePosition=27  Message=Unexpected XML declaration. The XML declaration must be the first node in the document, and no white space characters are allowed to appear before it. Line 122, position 27.  Source=System.Xml  SourceUri=""  StackTrace:       at System.Xml.XmlTextReaderImpl.Throw(Exception e)       at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)       at System.Xml.XmlTextReaderImpl.ParsePI(StringBuilder piInDtdStringBuilder)       at System.Xml.XmlTextReaderImpl.ParseDocumentContent()       at System.Xml.XmlTextReaderImpl.Read()       at ThinkGeo.MapSuite.Core.XmlGeoSerializationFormatter.xBQ=(XmlReader 4RU=)       at ThinkGeo.MapSuite.Core.XmlGeoSerializationFormatter.LoadCore(Stream stream)       at ThinkGeo.MapSuite.Core.GeoSerializationFormatter.Load(Stream stream)       at ThinkGeo.MapSuite.Core.GeoSerializer.Deserialize(Stream sourceStream)       at SerializeProjectedLayer.Form1.DeSerializeShapefile() in C:\Users\steller\Documents\Visual Studio 2010\Projects\ThinkGeo\SerializeProjectedLayer\Form1.vb:line 99       at SerializeProjectedLayer.Form1.btnDeserialize_Click(Object sender, EventArgs e) in C:\Users\steller\Documents\Visual Studio 2010\Projects\ThinkGeo\SerializeProjectedLayer\Form1.vb:line 165       at System.Windows.Forms.Control.OnClick(EventArgs e)       at System.Windows.Forms.Button.OnClick(EventArgs e)       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)       at System.Windows.Forms.Control.WndProc(Message& m)       at System.Windows.Forms.ButtonBase.WndProc(Message& m)       at System.Windows.Forms.Button.WndProc(Message& m)       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)       at SerializeProjectedLayer.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)       at System.Threading.ThreadHelper.ThreadStart()`

I&nbsp;have&nbsp;attached&nbsp;a&nbsp;sample&nbsp;project&nbsp;so&nbsp;you&nbsp;can&nbsp;see&nbsp;exactly&nbsp;what&nbsp;my&nbsp;code&nbsp;is&nbsp;doing.&nbsp;What&nbsp;can&nbsp;I&nbsp;do&nbsp;to&nbsp;fix&nbsp;this?

Thanks,

Steve

[SerializeShapefiles.zip](https://community.thinkgeo.com/uploads/default/original/1X/6a66c01efadd30801bf4e231e2e6965a053ff122.zip) (27.6 KB)

---

<div class="post-metadata">

**Author:** ![Johnny](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/johnny/32/19044_2.png) [@Johnny](https://community.thinkgeo.com/u/Johnny)\
**Post date:** [July 10, 2012, 9:18pm UTC](https://community.thinkgeo.com/t/how-to-serialize-multiple-layers-in-a-single-file/2017/2 "2012-07-10T21:18:52Z")

</div>

Hi&nbsp;Steven,

We&nbsp;apologize&nbsp;for&nbsp;the&nbsp;delay&nbsp;and&nbsp;any&nbsp;inconvenience&nbsp;this&nbsp;may&nbsp;cause.&nbsp;  
  
  
  
Thanks&nbsp;for&nbsp;your&nbsp;detailed&nbsp;information&nbsp;of&nbsp;this&nbsp;issue,&nbsp;I&nbsp;checked&nbsp;the&nbsp;demo&nbsp;code&nbsp;you&nbsp;provided,&nbsp;seems&nbsp;&nbsp;that&nbsp;you&nbsp;saved&nbsp;2&nbsp;serialized&nbsp;ShapeFileLayer&nbsp;string&nbsp;into&nbsp;a&nbsp;single&nbsp;file&nbsp;“Shapefile.wxd”,&nbsp;I&nbsp;think&nbsp;this&nbsp;should&nbsp;be&nbsp;the&nbsp;problem,&nbsp;actually,&nbsp;if&nbsp;we&nbsp;call&nbsp;“**GeoSerializer.Serializer()”&nbsp;**once,&nbsp;it&nbsp;will&nbsp;generate&nbsp;a&nbsp;complete&nbsp;Xml&nbsp;string&nbsp;which&nbsp;starts&nbsp;with&nbsp;“\<?xml&nbsp;version="1.0"&nbsp;encoding="utf-8"?\>”,&nbsp;if&nbsp;twice,&nbsp;it&nbsp;will&nbsp;generate&nbsp;2&nbsp;copy&nbsp;of&nbsp;complete&nbsp;XMl&nbsp;string,&nbsp;in&nbsp;other&nbsp;words,&nbsp;if&nbsp;we&nbsp;check&nbsp;the&nbsp;content&nbsp;of&nbsp;the&nbsp;“Shapefile.wxd”,&nbsp;it&nbsp;should&nbsp;be&nbsp;as&nbsp;following,&nbsp;it’s&nbsp;not&nbsp;allowed:

![](https://community.thinkgeo.com/uploads/default/original/2X/2/26ab4c5f319320d5cdb1b6c35e8eaa56bfd1d0e9.PNG)  
  
  
  
There&nbsp;are&nbsp;2&nbsp;ways&nbsp;to&nbsp;resolve&nbsp;the&nbsp;problem:  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1.Serialize&nbsp;different&nbsp;layer&nbsp;into&nbsp;different&nbsp;“.wxd”&nbsp;file.&nbsp;  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2.Serialize&nbsp;and&nbsp;de-serialize&nbsp;2&nbsp;layers&nbsp;at&nbsp;the&nbsp;same&nbsp;time.

Best&nbsp;Regards!  
  
Johnny  
  
&nbsp;

---

<div class="post-metadata">

**Author:** ![Steven1](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/steven1/32/18983_2.png) [@Steven1](https://community.thinkgeo.com/u/Steven1)\
**Post date:** [July 11, 2012, 7:27am UTC](https://community.thinkgeo.com/t/how-to-serialize-multiple-layers-in-a-single-file/2017/3 "2012-07-11T07:27:27Z")

</div>

Johnny,&nbsp;  
  
  
  
Thanks&nbsp;for&nbsp;your&nbsp;response.&nbsp;I&nbsp;was&nbsp;afraid&nbsp;that&nbsp;was&nbsp;what&nbsp;you&nbsp;were&nbsp;going&nbsp;to&nbsp;say.&nbsp;&nbsp;  
  
  
  
In&nbsp;order&nbsp;for&nbsp;serialization&nbsp;to&nbsp;be&nbsp;useful&nbsp;to&nbsp;us,&nbsp;we&nbsp;must&nbsp;be&nbsp;able&nbsp;to&nbsp;serialize&nbsp;the&nbsp;entire&nbsp;'Workspace'&nbsp;into&nbsp;a&nbsp;single&nbsp;file.&nbsp;Our&nbsp;'Workspace'&nbsp;consists&nbsp;of&nbsp;one&nbsp;or&nbsp;more&nbsp;maps,&nbsp;one&nbsp;or&nbsp;more&nbsp;'Page&nbsp;Layout'&nbsp;maps&nbsp;and&nbsp;the&nbsp;layers&nbsp;in&nbsp;the&nbsp;maps.&nbsp;When&nbsp;restoring&nbsp;a&nbsp;'session'&nbsp;we&nbsp;don't&nbsp;want&nbsp;to&nbsp;have&nbsp;to&nbsp;read&nbsp;several&nbsp;different&nbsp;files,&nbsp;but&nbsp;just&nbsp;one.&nbsp;The&nbsp;idea&nbsp;of&nbsp;us&nbsp;being&nbsp;able&nbsp;to&nbsp;serialize&nbsp;a&nbsp;session&nbsp;into&nbsp;a&nbsp;file&nbsp;that&nbsp;would&nbsp;still&nbsp;be&nbsp;usable&nbsp;when&nbsp;new&nbsp;versions&nbsp;of&nbsp;MS&nbsp;Desktop&nbsp;become&nbsp;available&nbsp;is&nbsp;very&nbsp;appealing.&nbsp;Many&nbsp;times&nbsp;when&nbsp;we&nbsp;move&nbsp;to&nbsp;a&nbsp;newer&nbsp;version&nbsp;the&nbsp;existing&nbsp;files&nbsp;we&nbsp;created&nbsp;from&nbsp;binary&nbsp;serialization&nbsp;will&nbsp;no&nbsp;longer&nbsp;work&nbsp;properly.&nbsp;  
  
  
  
Would&nbsp;it&nbsp;be&nbsp;possible&nbsp;for&nbsp;ThinkGeo&nbsp;to&nbsp;provide&nbsp;a&nbsp;method&nbsp;(in&nbsp;some&nbsp;future&nbsp;version)&nbsp;to&nbsp;serialize&nbsp;everything&nbsp;to&nbsp;a&nbsp;single&nbsp;file?&nbsp;  
  
  
  
Thanks!&nbsp;  
  
  
  
Steve

---

<div class="post-metadata">

**Author:** ![David](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@David](https://community.thinkgeo.com/u/David)\
**Post date:** [July 11, 2012, 8:22am UTC](https://community.thinkgeo.com/t/how-to-serialize-multiple-layers-in-a-single-file/2017/4 "2012-07-11T08:22:01Z")

</div>

Steven,&nbsp;  
&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;One&nbsp;thing&nbsp;that&nbsp;we&nbsp;do&nbsp;in&nbsp;our&nbsp;Gis&nbsp;Editor&nbsp;is&nbsp;that&nbsp;we&nbsp;also&nbsp;want&nbsp;one&nbsp;file&nbsp;for&nbsp;portability&nbsp;and&nbsp;such.&nbsp;&nbsp;How&nbsp;we&nbsp;handle&nbsp;this&nbsp;is&nbsp;we&nbsp;use&nbsp;a&nbsp;popular&nbsp;zip&nbsp;library&nbsp;that&nbsp;allows&nbsp;us&nbsp;to&nbsp;have&nbsp;one&nbsp;zip&nbsp;file&nbsp;that&nbsp;contains&nbsp;multiple&nbsp;other&nbsp;files&nbsp;inside.&nbsp;&nbsp;Since&nbsp;it&nbsp;supports&nbsp;sub&nbsp;directories&nbsp;directories&nbsp;you&nbsp;can&nbsp;easily&nbsp;organize&nbsp;the&nbsp;data&nbsp;within&nbsp;however&nbsp;you&nbsp;want.&nbsp;&nbsp;The&nbsp;great&nbsp;part&nbsp;is&nbsp;that&nbsp;you&nbsp;can&nbsp;insert,&nbsp;remove,&nbsp;read&nbsp;and&nbsp;modify&nbsp;data&nbsp;inside&nbsp;the&nbsp;zip&nbsp;file&nbsp;using&nbsp;streams&nbsp;so&nbsp;there&nbsp;is&nbsp;never&nbsp;any&nbsp;reason&nbsp;to&nbsp;actually&nbsp;open&nbsp;the&nbsp;file&nbsp;on&nbsp;the&nbsp;disk.&nbsp;&nbsp;The&nbsp;program&nbsp;sees&nbsp;it&nbsp;as&nbsp;separate&nbsp;files&nbsp;but&nbsp;its&nbsp;all&nbsp;together.&nbsp;&nbsp;&nbsp;  
&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;In&nbsp;our&nbsp;product&nbsp;when&nbsp;you&nbsp;save&nbsp;a&nbsp;project&nbsp;we&nbsp;have&nbsp;just&nbsp;one&nbsp;file&nbsp;but&nbsp;that&nbsp;file&nbsp;contains&nbsp;the&nbsp;complete&nbsp;map&nbsp;control&nbsp;serialized,&nbsp;it&nbsp;contains&nbsp;a&nbsp;thumbnail&nbsp;snapshot&nbsp;of&nbsp;the&nbsp;map,&nbsp;for&nbsp;preview&nbsp;purposed,&nbsp;it&nbsp;contains&nbsp;a&nbsp;bunch&nbsp;of&nbsp;XML&nbsp;files&nbsp;as&nbsp;well&nbsp;for&nbsp;setting&nbsp;and&nbsp;could&nbsp;even&nbsp;contain&nbsp;data&nbsp;files&nbsp;if&nbsp;we&nbsp;wanted&nbsp;or&nbsp;just&nbsp;about&nbsp;anything.&nbsp;&nbsp;The&nbsp;other&nbsp;nice&nbsp;thing&nbsp;about&nbsp;this&nbsp;is&nbsp;that&nbsp;if&nbsp;push&nbsp;comes&nbsp;to&nbsp;show&nbsp;and&nbsp;a&nbsp;user&nbsp;sent&nbsp;us&nbsp;his&nbsp;project&nbsp;we&nbsp;could&nbsp;unzip&nbsp;it,&nbsp;could&nbsp;also&nbsp;support&nbsp;passwords.&nbsp;:-),&nbsp;and&nbsp;we&nbsp;can&nbsp;look&nbsp;at&nbsp;all&nbsp;the&nbsp;XML&nbsp;files,&nbsp;make&nbsp;modification&nbsp;and&nbsp;send&nbsp;it&nbsp;back.&nbsp;&nbsp;One&nbsp;reason&nbsp;I&nbsp;suggest&nbsp;separate&nbsp;XML&nbsp;files&nbsp;is&nbsp;that&nbsp;if&nbsp;you&nbsp;put&nbsp;settings,&nbsp;map&nbsp;state&nbsp;etc&nbsp;in&nbsp;one&nbsp;file&nbsp;it&nbsp;is&nbsp;more&nbsp;likely&nbsp;there&nbsp;will&nbsp;be&nbsp;a&nbsp;problem&nbsp;where&nbsp;your&nbsp;XML&nbsp;is&nbsp;not&nbsp;well&nbsp;formed&nbsp;and&nbsp;it&nbsp;makes&nbsp;your&nbsp;recovery&nbsp;that&nbsp;much&nbsp;harder.&nbsp;&nbsp;Separate&nbsp;files&nbsp;isolates&nbsp;issues&nbsp;and&nbsp;allows&nbsp;you&nbsp;to&nbsp;possibly&nbsp;recover&nbsp;parts&nbsp;of&nbsp;a&nbsp;project&nbsp;even&nbsp;if&nbsp;other&nbsp;parts&nbsp;fail.&nbsp;  
&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;Ok,&nbsp;maybe&nbsp;way&nbsp;more&nbsp;than&nbsp;what&nbsp;you&nbsp;were&nbsp;thinking&nbsp;but&nbsp;I&nbsp;wanted&nbsp;to&nbsp;share.&nbsp;  
&nbsp;&nbsp;  
&nbsp;David

---

<div class="post-metadata">

**Author:** ![Steven1](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/steven1/32/18983_2.png) [@Steven1](https://community.thinkgeo.com/u/Steven1)\
**Post date:** [July 11, 2012, 8:51am UTC](https://community.thinkgeo.com/t/how-to-serialize-multiple-layers-in-a-single-file/2017/5 "2012-07-11T08:51:16Z")

</div>

Hi&nbsp;David,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks&nbsp;for&nbsp;your&nbsp;response,&nbsp;you&nbsp;make&nbsp;some&nbsp;very&nbsp;good&nbsp;points,&nbsp;and&nbsp;it&nbsp;gives&nbsp;me&nbsp;a&nbsp;different&nbsp;way&nbsp;to&nbsp;think&nbsp;about&nbsp;it.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Steve

---

<div class="post-metadata">

**Author:** ![Ted](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/t/db5fbb/32.png) [@Ted](https://community.thinkgeo.com/u/Ted)\
**Post date:** [July 11, 2012, 9:31am UTC](https://community.thinkgeo.com/t/how-to-serialize-multiple-layers-in-a-single-file/2017/6 "2012-07-11T09:31:42Z")

</div>

David,&nbsp;I’m&nbsp;just&nbsp;&nbsp;a&nbsp;lurker&nbsp;on&nbsp;this,&nbsp;but&nbsp;I&nbsp;really&nbsp;like&nbsp;what&nbsp;you&nbsp;have&nbsp;described&nbsp;here,&nbsp;too.&nbsp;&nbsp;&nbsp;I’m&nbsp;especially&nbsp;interested&nbsp;in&nbsp;exploring&nbsp;the&nbsp;ability&nbsp;to&nbsp;stream&nbsp;directly&nbsp;from&nbsp;a&nbsp;the&nbsp;zip&nbsp;files&nbsp;as&nbsp;we&nbsp;move&nbsp;lots&nbsp;of&nbsp;data&nbsp;around&nbsp;with&nbsp;the&nbsp;zipping&nbsp;engine&nbsp;that&nbsp;we&nbsp;use.

---

<div class="post-metadata">

**Author:** ![David](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@David](https://community.thinkgeo.com/u/David)\
**Post date:** [July 11, 2012, 9:42am UTC](https://community.thinkgeo.com/t/how-to-serialize-multiple-layers-in-a-single-file/2017/7 "2012-07-11T09:42:42Z")

</div>

Ted,&nbsp;  
&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;I&nbsp;am&nbsp;pretty&nbsp;sure&nbsp;we&nbsp;use&nbsp;SharpZipLib&nbsp;which&nbsp;is&nbsp;free&nbsp;and&nbsp;pretty&nbsp;easy&nbsp;to&nbsp;use.&nbsp;&nbsp;We&nbsp;may&nbsp;have&nbsp;replaced&nbsp;it&nbsp;but&nbsp;I’m&nbsp;not&nbsp;sure&nbsp;and&nbsp;will&nbsp;check&nbsp;on&nbsp;that.&nbsp;&nbsp;The&nbsp;nicest&nbsp;thing&nbsp;is&nbsp;portability&nbsp;of&nbsp;a&nbsp;bunch&nbsp;of&nbsp;semi&nbsp;related&nbsp;items.&nbsp;&nbsp;Also&nbsp;if&nbsp;push&nbsp;comes&nbsp;to&nbsp;shove&nbsp;I&nbsp;can&nbsp;unzip&nbsp;it&nbsp;and&nbsp;get&nbsp;to&nbsp;all&nbsp;the&nbsp;content.&nbsp;&nbsp;Also&nbsp;the&nbsp;password&nbsp;protection&nbsp;piece&nbsp;is&nbsp;nice&nbsp;as&nbsp;well&nbsp;as&nbsp;well&nbsp;as&nbsp;the&nbsp;side&nbsp;effect&nbsp;of&nbsp;compression.&nbsp;&nbsp;The&nbsp;one&nbsp;thing&nbsp;that&nbsp;is&nbsp;not&nbsp;that&nbsp;nice&nbsp;is&nbsp;that&nbsp;the&nbsp;streams&nbsp;are&nbsp;not&nbsp;random&nbsp;access&nbsp;so&nbsp;you&nbsp;read&nbsp;or&nbsp;write&nbsp;the&nbsp;whole&nbsp;file&nbsp;at&nbsp;a&nbsp;time.&nbsp;&nbsp;You&nbsp;can’t&nbsp;really&nbsp;go&nbsp;in&nbsp;and&nbsp;modify&nbsp;a&nbsp;part&nbsp;of&nbsp;a&nbsp;file.&nbsp;&nbsp;This&nbsp;is&nbsp;ok&nbsp;for&nbsp;state&nbsp;and&nbsp;setting&nbsp;but&nbsp;for&nbsp;data&nbsp;we&nbsp;need&nbsp;to&nbsp;unpack&nbsp;it&nbsp;and&nbsp;set&nbsp;it&nbsp;up&nbsp;somewhere&nbsp;temporary.&nbsp;  
&nbsp;&nbsp;  
&nbsp;David

---

<div class="post-metadata">

**Author:** ![Ted](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/t/db5fbb/32.png) [@Ted](https://community.thinkgeo.com/u/Ted)\
**Post date:** [July 11, 2012, 9:49am UTC](https://community.thinkgeo.com/t/how-to-serialize-multiple-layers-in-a-single-file/2017/8 "2012-07-11T09:49:50Z")

</div>

We’ve&nbsp;used&nbsp;SharpZipLib&nbsp;since&nbsp;we&nbsp;started&nbsp;programming&nbsp;in&nbsp;.Net.&nbsp;&nbsp;&nbsp;But&nbsp;recently&nbsp;shifted&nbsp;to&nbsp;some&nbsp;7z&nbsp;free&nbsp;library.&nbsp;&nbsp;&nbsp;On&nbsp;our&nbsp;kind&nbsp;of&nbsp;data,&nbsp;the&nbsp;improved&nbsp;compression&nbsp;was&nbsp;really&nbsp;amazing.

---

<div class="post-metadata">

**Author:** ![David](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@David](https://community.thinkgeo.com/u/David)\
**Post date:** [July 11, 2012, 9:54am UTC](https://community.thinkgeo.com/t/how-to-serialize-multiple-layers-in-a-single-file/2017/9 "2012-07-11T09:54:05Z")

</div>

Ted,&nbsp;  
&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;7z&nbsp;is&nbsp;the&nbsp;compression&nbsp;king&nbsp;for&nbsp;sure,&nbsp;I&nbsp;didn’t&nbsp;know&nbsp;they&nbsp;had&nbsp;a&nbsp;.net&nbsp;library&nbsp;though.&nbsp;&nbsp;:-)&nbsp;&nbsp;Always&nbsp;a&nbsp;pleasure&nbsp;chatting&nbsp;with&nbsp;you&nbsp;Ted!&nbsp;  
&nbsp;&nbsp;  
&nbsp;David

---

<div class="post-metadata">

**Author:** ![Steven1](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/steven1/32/18983_2.png) [@Steven1](https://community.thinkgeo.com/u/Steven1)\
**Post date:** [July 11, 2012, 9:57am UTC](https://community.thinkgeo.com/t/how-to-serialize-multiple-layers-in-a-single-file/2017/10 "2012-07-11T09:57:24Z")

</div>

Guys,&nbsp;  
&nbsp;&nbsp;  
&nbsp;I&nbsp;have&nbsp;been&nbsp;using&nbsp;7z&nbsp;and&nbsp;it’s&nbsp;the&nbsp;best&nbsp;tool&nbsp;for&nbsp;creating&nbsp;zip&nbsp;files&nbsp;(and&nbsp;other&nbsp;types)&nbsp;I’ve&nbsp;ever&nbsp;used,&nbsp;and&nbsp;free&nbsp;to&nbsp;boot.&nbsp;I’ve&nbsp;only&nbsp;used&nbsp;the&nbsp;graphical&nbsp;front&nbsp;end,&nbsp;but&nbsp;now&nbsp;I’ll&nbsp;probably&nbsp;investigate&nbsp;implementing&nbsp;some&nbsp;of&nbsp;your&nbsp;suggestions,&nbsp;David.&nbsp;Thanks,&nbsp;guys,&nbsp;for&nbsp;the&nbsp;ideas.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Steve

---

<div class="post-metadata">

**Author:** ![Gary2](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/g/49beb7/32.png) [@Gary2](https://community.thinkgeo.com/u/Gary2)\
**Post date:** [July 11, 2012, 4:59pm UTC](https://community.thinkgeo.com/t/how-to-serialize-multiple-layers-in-a-single-file/2017/11 "2012-07-11T16:59:56Z")

</div>

Hello&nbsp;Steven,&nbsp;  
&nbsp;&nbsp;  
&nbsp;If&nbsp;you&nbsp;still&nbsp;meet&nbsp;any&nbsp;problems,&nbsp;don’t&nbsp;hesitate&nbsp;to&nbsp;let&nbsp;us&nbsp;know.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Regards,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Gary
