[GIS] How to determine the version of an SDF file

mapguidesdf

I'm looking for a tool or a method to reliably determine which SDF version a given file is implementing.

So far I've been using Autodesk's SDF Loader with the /info flag, but it only supports SDFv2.

Unfortunately I have a large number of SDF files of various version where i need determine which ones need to be upgraded to SDFv3. As FDO Toolbox only supports SDFv3 and we are upgrading from MapGuide 6.5 which only supports SDFv2.

So in summary I'm looking for a reliable way to determine the major and minor version number of the SDF file hopefully in a single tool. (I'm aware of FME, leaving it as a last resort due to cost)

Best Answer

When you try to connect to a SDF < 3.0 file with FDO, the SDF provider will throw an exception with a specific message (SDF file appears to be version 2.1 or older. Please convert to SDF version 3)

Therefore an ugly, but workable feasible solution is to employ the following logic in C#:

try {
    //Try to connect using FDO. If you can open/close without exceptions, it's a valid SDF3 file
} catch (OSGeo.FDO.Common.Exception ex) {
    if (ex.Message == "SDF file appears to be version 2.1 or older. Please convert to SDF version 3") {
        //Try using SDF loader. If you can open/close without errors, it's a valid SDFv2 file
    }
}