Engine中如何将mapSurroundFrame对象序列化为xml?

Engine中如何将mapSurroundFrame对象序列化为xml?比如指北针
已邀请:

朱新颖

赞同来自:

【解决办法】:
使用IPersistStream 进行序列化和反序列化。


//序列化:
IMemoryBlobStream pMBStream = new MemoryBlobStreamClass();
IObjectStream pOStream = new ObjectStreamClass();
pOStream.Stream = pMBStream;
IPersistStream pPStream = (IPersistStream)mapSurroundFrame;
pPStream.Save(pOStream, 1);
pMBStream.SaveToFile(D:\\book.xml); 

//反序列化:
IObjectStream pObjectStream = new ObjectStreamClass();
IMemoryBlobStream pMemoryBlobStream = new MemoryBlobStreamClass();
pMemoryBlobStream.LoadFromFile(D:\\book.xml);
IPersistStream pPersistStream = (IPersistStream)mapSurroundFrame;
pObjectStream.Stream = pMemoryBlobStream;
pPersistStream.Load(pObjectStream); 

要回复问题请先登录注册