Select to view content in your preferred language

How to access DateModified for a raster dataset?

4436
2
12-30-2014 06:19 PM
LesleyBross
Deactivated User

I need to retrieve the date modified for each feature class and raster in a file geodatabase. I have been able to accomplish this using the IDatasetFileStat interface for the feature classes using the methodology described here. However, I've been unable to find a raster class that implements the IDatasetFileStat. The documentation indicates that the RasterDataset should implement this interface but when I try to cast it, I get an InvalidCastException.

                    pGDS = BA_OpenRasterFromGDB(gdbPath, layerRasterList(i))  'My custom function that opens a raster and returns IGeodataset

                    If pGDS IsNot Nothing Then

                        pRasterBandCollection = CType(pGDS, IRasterBandCollection) 'Explicit cast

                        pRasterBand = pRasterBandCollection.Item(0)

                        Dim myTest As RasterDataset = pRasterBand.RasterDataset

                        pDFS = CType(myTest, IDatasetFileStat)     'Invalid cast exception occurs here

                        Dim intSeconds As Integer = pDFS.StatTime(esriDatasetFileStatTimeMode.esriDatasetFileStatTimeLastModification)

Any suggestions?

Tags (1)
0 Kudos
2 Replies
AlexanderNohe1
Honored Contributor

Hi Lesley,

For some reason, I do not believe that this attribute is possible.  If you take a look at the following screenshot I recorded, I turned on the modified property in catalog and raster data sets do not show any information for modified.

I hope this helps!

NoModDate.png

LesleyBross
Deactivated User

Hi Alexander ~

After further research, I believe you are correct. I'd like to add to this discussion that I found the IDatasetNameFileStat2 to be a more efficient interface to use for this purpose (for vector data) as you only have to get a handle to the IDatasetName rather than having to open the dataset.

It is unfortunate that ESRI does not manage this attribute for raster data sets in FGDB format. I found that it does work for rasters stored in a plain file system. Thanks -- Lesley

0 Kudos