I have a simple code to create new document in ArcMap and add one layer from file (.lyr). Code runs on a click of add-in button.
If I run this code, ArcMap always shows "Do you want to save..?" dialog.
Here is the code:
In fact, I want to have a code, which acts the same as "New Map File" ArcMap command.
Any ideas?
If I run this code, ArcMap always shows "Do you want to save..?" dialog.
Here is the code:
Code:
public class TestNewDoc : ESRI.ArcGIS.Desktop.AddIns.Button
{
protected override void OnClick()
{
ArcMap.Application.OpenDocument("Normal.mxt");
IGxLayer gxLayer = new GxLayerClass();
IGxFile gxFile = (IGxFile)gxLayer;
gxFile.Path = "C:\\temp\\layer.lyr";
ArcMap.Document.AddLayer(gxLayer.Layer);
}
}
Any ideas?