string unpackPath = ""; IPackageFile pkFile = new PackageFileClass(); pkFile.Unpack(@C:\temp\tpk\TPK_Map.tpk, ref unpackPath); axMapControl1.AddLayerFromFile(unpackPath + "\\Layers.lyr");
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"); } } } } }
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.