Detect if a FGDB table/featureclass is compressed

1682
2
Jump to solution
10-27-2014 10:41 AM
WayneGuidry
New Contributor III

Is it possible to detect if a file geodatabase table/feature class is compressed or uncompressed using code (preferably C#)?

0 Kudos
1 Solution

Accepted Solutions
VinceAngelo
Esri Esteemed Contributor

I got this from a colleague:

        public static Boolean IsCompressed(IDataset dataset)

        {

           // Check the table's workspace type.

           IWorkspace workspace = dataset.Workspace;

           WorkspaceType workspaceType = GetWorkspaceType(workspace);

           if (workspaceType == WorkspaceType.FileGDB)

           {

              // Get the dataset's property set and check the "Datafile Format" property.

              IPropertySet propertySet = dataset.PropertySet;

              if (propertySet != null)

              {

                 try

                 {

                    object propertyValue = propertySet.GetProperty("Datafile Format");

                    esriFGDBDatafileFormat datafileFormat = (esriFGDBDatafileFormat)propertyValue;

                    if (datafileFormat == esriFGDBDatafileFormat.esriFGDBCompressedDatafile)

                    {

                       return true;

                    }

                 }

                 catch (InvalidCastException) { }

              }

           }

           return false;

        }

He notes that FileGDB workspaces and feature datasets do not know if they are in a compressed file geodatabase, only tables and feature classes.

View solution in original post

0 Kudos
2 Replies
VinceAngelo
Esri Esteemed Contributor

I got this from a colleague:

        public static Boolean IsCompressed(IDataset dataset)

        {

           // Check the table's workspace type.

           IWorkspace workspace = dataset.Workspace;

           WorkspaceType workspaceType = GetWorkspaceType(workspace);

           if (workspaceType == WorkspaceType.FileGDB)

           {

              // Get the dataset's property set and check the "Datafile Format" property.

              IPropertySet propertySet = dataset.PropertySet;

              if (propertySet != null)

              {

                 try

                 {

                    object propertyValue = propertySet.GetProperty("Datafile Format");

                    esriFGDBDatafileFormat datafileFormat = (esriFGDBDatafileFormat)propertyValue;

                    if (datafileFormat == esriFGDBDatafileFormat.esriFGDBCompressedDatafile)

                    {

                       return true;

                    }

                 }

                 catch (InvalidCastException) { }

              }

           }

           return false;

        }

He notes that FileGDB workspaces and feature datasets do not know if they are in a compressed file geodatabase, only tables and feature classes.

0 Kudos
WayneGuidry
New Contributor III

Nice, exactly what I needed. thanks!

0 Kudos