Hi,
I am creating a raster layer in ArcMap 10.1 and displaying it in the map:
CComPtr<IRasterLayer> iRasterLayer;
iRasterLayer.CoCreateInstance(CLSID_RasterLayer);
iRasterLayer->CreateFromFilePath(rasterFile);
m_pMap->AddLayer(iRasterLayer);
The file on disk that is at the rasterFile location is later changed by some other software and I want the map to reflect that change. I have tried many different approaches with no success. For example, I tried the obvious which was to remove the raster layer from the map, then create a new raster layer as in the code above. Even in that case, it still displays the OLD image, not the updated one. I am assuming there is some cacheing going on that is based strictly on the filename. My only recourse has been to restart ArcMap which of course is not an acceptable workaround.
Does anyone have any advice? My preference is to do something at the original RasterLayer object level (e.g. telling it to reload/clear cache, etc.), but anything short of restarting ArcMap would be an improvement.
BTW, this issue is not specific to ArcObjects. I can reproduce the same behavior by adding the raster file interactively via the ArcMap GUI, removing the layer, updating the file, then adding the file via the GUI again. But, I am hoping there is something I can call in ArcObjects to address this issue.
Thanks,
Kyle