You can make use of IPackageFile.Unpack to unpack the TPK prior to adding its layer:string unpackPath = "";
IPackageFile pkFile = new PackageFileClass();
pkFile.Unpack(@"C:\temp\tpk\TPK_Map.tpk", ref unpackPath);
axMapControl1.AddLayerFromFile(unpackPath + "\\Layers.lyr");
I like to enable OLEDrop and click/drag them to the map control, here is a trimmed down version of that code:private void axMapControl1_OnOleDrop(object sender, IMapControlEvents2_OnOleDropEvent e)
{
IDataObjectHelper dataObject = (IDataObjectHelper)e.dataObjectHelper;
if (e.dropAction == esriControlsDropAction.esriDropped)
{
if (dataObject.CanGetFiles())
{
System.Array filePaths = System.Array.CreateInstance(typeof(string), 0, 0);
filePaths = (System.Array)dataObject.GetFiles();
for (int i = 0; i <= filePaths.Length - 1; i++)
{
string filePath = filePaths.GetValue(i).ToString();
if (filePath.Contains(".tpk"))
{
string unpackPath = "";
IPackageFile pkFile = new PackageFileClass();
pkFile.Unpack(@"C:\temp\tpk\TPK_Map.tpk", ref unpackPath);
axMapControl1.AddLayerFromFile(unpackPath + "\\Layers.lyr");
}
}
}
}
}