/// <summary>
/// 将.layer保存成.lyr文件
/// </summary>
/// <param name="pLayer"></param>
/// <param name="strLyr"></param>
private void SaveToLyrFromLayer(IFeatureLayer pLayer, string strLyr)
{
try
{
//Engine中的BlobStream对象
IMemoryBlobStream pBlobStream = new MemoryBlobStreamClass();
IObjectStream pObject = new ObjectStreamClass();
pObject.Stream = pBlobStream;
IPersistStream pPerStreamout = (IPersistStream)pLayer;
//存入BlobStream
pPerStreamout.Save(pObject, 0);
pBlobStream.SaveToFile(strLyr);
}
catch (Exception excp)
{
}
}
/// <summary>
/// 从.lyr文件中读取成.layer
/// </summary>
/// <param name="strLyr"></param>
/// <param name="player"></param>
/// <returns></returns>
private IFeatureLayer GetLayerFromLyr(string strLyr, IFeatureLayer player)
{
try
{
IMemoryBlobStream pBlobStream = new MemoryBlobStreamClass();
pBlobStream.LoadFromFile(strLyr);
IObjectStream pObjectStreamout =new ObjectStreamClass();
pObjectStreamout.Stream = pBlobStream;
IPersistStream pP = (IPersistStream)player;
pP.Load((IStream)pObjectStreamout);
return player;
}
catch (Exception excp)
{
return null;
}
}