file geodatabase path

153
2
09-19-2018 02:40 PM
Highlighted
New Contributor

I'm using Pro SDK 2.0 and have a geodatabase object for a file geodatabase. I'd like to get the file path of the geodatabase but haven't been able to figure out how?

Reply
0 Kudos
2 Replies
Highlighted
MVP Esteemed Contributor

trying out the sdk help files... but I probably have the wrong one...

ArcGIS Pro 2.2 API Reference Guide or

ArcGIS Pro 2.2 API Reference Guide 

FileGeodatabaseConnectionPath Class

Represents the physical path to a file geodatabase folder that ends with the .gdb extension.

Reply
0 Kudos
Highlighted
by Esri Regular Contributor
Esri Regular Contributor

Here is a snippet that explains how to get the path:

QueuedTask.Run(() =>
  {
         using (Geodatabase defaultGeodatabase = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(Project.Current.DefaultGeodatabasePath))))
         {
           FileGeodatabaseConnectionPath connectionPath = (FileGeodatabaseConnectionPath)defaultGeodatabase.GetConnector();
           MessageBox.Show($@"Path: {connectionPath.Path}");
         }
  });

You can paste this into the OnClick of a button Add-in to test it out.

Hope this helps,

Wolf