Detect if a FGDB table/featureclass is compressed

1490
2
Jump to solution
10-27-2014 10:41 AM
Highlighted
New Contributor III

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

Reply
0 Kudos
1 Solution

Accepted Solutions
Highlighted
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

Reply
0 Kudos
2 Replies
Highlighted
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

Reply
0 Kudos
Highlighted
New Contributor III

Nice, exactly what I needed. thanks!

Reply
0 Kudos