How to save a layer file

This document describes the process of saving a layer in your map as a file on disk.

Saving a layer file

One of the main features of a layer is that it can exist outside your map as a file on disk. This makes it easy for others to access the layers you've built.
When you save a layer to disk, you save everything about the layer, such as the symbolization and labeling. When you add a layer file to another map, it will draw exactly as it was saved. Others can drop these layers onto their maps without having to know how to access the database or classify the data; this can be helpful when sharing data stored in a multiuser geodatabase with nontechnical staff members. You can share layers over a network and e-mail layers with the data or enclose the layer in the data's metadata.
To save layer files programmatically in an ArcGIS Engine application, do the following:
  1. Get the output path for the new layer file. The layer file must have a .lyr extension. See the following:
  1. Create a new instance of a LayerFile class—You will be using a LayerFile class to create a new instance of a layer file. See the following:
//Create a new LayerFile instance.
ILayerFile layerFile = new LayerFile();
//Create a new layer file.
  1. Bind the layer from the map with the newly created layer file—Once you have created the new layer file, you need to bind it with the current layer from the map that you intend to save to disk. See the following:
//Bind the layer file with the layer from the map.
  1. Save the layer file—To complete the operation, you must save the layer file. See the following:

Development licensingDeployment licensing
Engine Developer KitEngine
ArcGIS for Desktop BasicArcGIS for Desktop Basic
ArcGIS for Desktop StandardArcGIS for Desktop Standard
ArcGIS for Desktop AdvancedArcGIS for Desktop Advanced