Is it possible to detect if a file geodatabase table/feature class is compressed or uncompressed using code (preferably C#)?
Solved! Go to Solution.
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.
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.
Nice, exactly what I needed. thanks!