<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Loading *.tpk file for use as Basemap UWP in .NET Maps SDK Questions</title>
    <link>https://community.esri.com/t5/net-maps-sdk-questions/loading-tpk-file-for-use-as-basemap-uwp/m-p/1006265#M9606</link>
    <description>&lt;P&gt;Because UWP is running in a sandbox you can't read the TPK directly from disk.&lt;/P&gt;&lt;P&gt;Typically after picking the file, you'd need to copy it inside the sandbox using Storage APIs, typically the apps' Temp or Local Data folder.&lt;/P&gt;&lt;P&gt;As an alternative, you could give read access to the Windows system account user "ALL_APPLICATION_PACKAGES", which would allow your app to read it directly (that's good for quick testing, but probably not in a production scenario).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The documentation is a bit problematic because it doesn't account for this. We'll try and get that fixed&lt;/P&gt;</description>
    <pubDate>Wed, 02 Dec 2020 18:24:32 GMT</pubDate>
    <dc:creator>dotMorten_esri</dc:creator>
    <dc:date>2020-12-02T18:24:32Z</dc:date>
    <item>
      <title>Loading *.tpk file for use as Basemap UWP</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/loading-tpk-file-for-use-as-basemap-uwp/m-p/1006240#M9605</link>
      <description>&lt;P&gt;I am trying to load a basemap for offline use.&amp;nbsp; I used ArcGISPro to creat a .tpk file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following is my code to load the tpk.&amp;nbsp; I am expecting the content of the tpk to be rendered in my Map, but it doesn't.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt; try
            {

                var picker = new Windows.Storage.Pickers.FileOpenPicker();
                picker.ViewMode = Windows.Storage.Pickers.PickerViewMode.Thumbnail;
                picker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary;
                picker.FileTypeFilter.Add(".tpk");
                picker.FileTypeFilter.Add(".mmpk");

                Windows.Storage.StorageFile file = await picker.PickSingleFileAsync();
                if (file != null)
                {
                    // Application now has read/write access to the picked file
                    var result  = "Picked photo: " + file.Name;
                }
                else
                {
                    var error = "Operation cancelled.";
                }

                TileCache cache = new TileCache(file.Path);
                
                ArcGISTiledLayer layer = new ArcGISTiledLayer(cache);
                ViewModel.Map = new Map(new Basemap(layer));
               
              
            }
            catch (Exception ex)
            {
                var tmp = ex.ToString();
            }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If i try to add a "await ViewModel.Map.LoadAsync()"&amp;nbsp; at the end of the code above.&amp;nbsp; It doesnt seem to load and i dont catch an exception either.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not sure what i am doing wrong.&amp;nbsp; &amp;nbsp;I chose this code based on the example posted &lt;A href="https://developers.arcgis.com/net/latest/uwp/guide/work-with-offline-layers.htm" target="_self"&gt;here:&amp;nbsp;https://developers.arcgis.com/net/latest/uwp/guide/work-with-offline-layers.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;attached is a zipped up tpk file that i am attempting load.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Dec 2020 17:42:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/loading-tpk-file-for-use-as-basemap-uwp/m-p/1006240#M9605</guid>
      <dc:creator>justinfernandes</dc:creator>
      <dc:date>2020-12-02T17:42:08Z</dc:date>
    </item>
    <item>
      <title>Re: Loading *.tpk file for use as Basemap UWP</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/loading-tpk-file-for-use-as-basemap-uwp/m-p/1006265#M9606</link>
      <description>&lt;P&gt;Because UWP is running in a sandbox you can't read the TPK directly from disk.&lt;/P&gt;&lt;P&gt;Typically after picking the file, you'd need to copy it inside the sandbox using Storage APIs, typically the apps' Temp or Local Data folder.&lt;/P&gt;&lt;P&gt;As an alternative, you could give read access to the Windows system account user "ALL_APPLICATION_PACKAGES", which would allow your app to read it directly (that's good for quick testing, but probably not in a production scenario).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The documentation is a bit problematic because it doesn't account for this. We'll try and get that fixed&lt;/P&gt;</description>
      <pubDate>Wed, 02 Dec 2020 18:24:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/loading-tpk-file-for-use-as-basemap-uwp/m-p/1006265#M9606</guid>
      <dc:creator>dotMorten_esri</dc:creator>
      <dc:date>2020-12-02T18:24:32Z</dc:date>
    </item>
    <item>
      <title>Re: Loading *.tpk file for use as Basemap UWP</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/loading-tpk-file-for-use-as-basemap-uwp/m-p/1006353#M9609</link>
      <description>&lt;P&gt;Thank you that worked !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;full solution is here:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt; try
            {

                var picker = new Windows.Storage.Pickers.FileOpenPicker();
                picker.ViewMode = Windows.Storage.Pickers.PickerViewMode.Thumbnail;
                picker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary;
                picker.FileTypeFilter.Add(".tpk");
                picker.FileTypeFilter.Add(".mmpk");

                Windows.Storage.StorageFile file = await picker.PickSingleFileAsync();
                var localFile = await Windows.Storage.ApplicationData.Current.TemporaryFolder.CreateFileAsync(file.Name, Windows.Storage.CreationCollisionOption.ReplaceExisting);
                await file.CopyAndReplaceAsync(localFile);

                if (localFile != null)
                {
                    // Application now has read/write access to the picked file
                    var result  = "Picked photo: " + localFile.Name;
                }
                else
                {
                    var error = "Operation cancelled.";
                }

                TileCache cache = new TileCache(localFile.Path);
                
                ArcGISTiledLayer layer = new ArcGISTiledLayer(cache);
                ViewModel.Map = new Map(new Basemap(layer));
               
              
            }
            catch (Exception ex)
            {
                var tmp = ex.ToString();
            }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the key snippet i added based on your suggestion was :&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;var localFile = await Windows.Storage.ApplicationData.Current.TemporaryFolder.CreateFileAsync(file.Name, Windows.Storage.CreationCollisionOption.ReplaceExisting);
                await file.CopyAndReplaceAsync(localFile);&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 02 Dec 2020 21:07:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/loading-tpk-file-for-use-as-basemap-uwp/m-p/1006353#M9609</guid>
      <dc:creator>justinfernandes</dc:creator>
      <dc:date>2020-12-02T21:07:25Z</dc:date>
    </item>
  </channel>
</rss>

