Retrieval of Project/project template metadata

474
6
Jump to solution
07-01-2020 10:49 PM
ThanHtetAung_EsriAu
Esri Regular Contributor

Hi Guys,

When we create the project template from a project, we need to add tags/description and few metadata. 

The question is that how we can retrieve these information from ArcGIS pro sdk by using the file path only(e.g. C:\....\template1.aptx).

One of my client want to see these before choosing any template to create a project from the predefined template. 

0 Kudos
1 Solution

Accepted Solutions
Wolf
by Esri Regular Contributor
Esri Regular Contributor

Hi Than,

 Pro is using the 7 zip library.  I attached a sample project to unzip a project file that appears to work for me, it should work for templates too.  Since Pro ships with the 7z dll you can set the path for the extractor to the Pro install bin folder (c:\ArcGIS is my install location):

// set 7z.dll path:
SevenZipExtractor.SetLibraryPath(@"C:\ArcGIS\Bin\7z.dll");

I also used the following NuGet: NuGet Gallery | SevenZipSharp.Interop 19.0.0  

View solution in original post

6 Replies
ThanHtetAung_EsriAu
Esri Regular Contributor

Hi Uma Harano‌ / Wolfgang Kaiser‌,

Any advice on how to get those project template file tag/description with sdk?

0 Kudos
Wolf
by Esri Regular Contributor
Esri Regular Contributor

Hi Than,

 This is not supported by the API.  However, these files are simple .zip files so as a possible solution you could write some code to unzip the file (project or template) and parse the content for your tags.  

ThanHtetAung_EsriAu
Esri Regular Contributor

Thank Wolfgang Kaiser‌ for your advice,

I will try and share if I achieved it

0 Kudos
Wolf
by Esri Regular Contributor
Esri Regular Contributor

Hi Than,

 Pro is using the 7 zip library.  I attached a sample project to unzip a project file that appears to work for me, it should work for templates too.  Since Pro ships with the 7z dll you can set the path for the extractor to the Pro install bin folder (c:\ArcGIS is my install location):

// set 7z.dll path:
SevenZipExtractor.SetLibraryPath(@"C:\ArcGIS\Bin\7z.dll");

I also used the following NuGet: NuGet Gallery | SevenZipSharp.Interop 19.0.0  

ThanHtetAung_EsriAu
Esri Regular Contributor

Thank Wolfgang Kaiser‌ for your sample, 

Found similar way in 7z.NET nugget as well and manage to extract out only one file, just have tried in normal console app.

Still trying to find a way to extract into memory stream instead of direct file extraction, 

Next step shall be implementing in the arcgis pro module.

0 Kudos
ThanHtetAung_EsriAu
Esri Regular Contributor

Added the sample code how to extract into memory and loaded into object.

https://community.esri.com/groups/arcgis-pro-sdk/blog/2020/07/09/reading-aptx-file 

0 Kudos