I'm creating an addin in which I need to delete the raster file after deleting it's layer from the current map.
The layer is deleted no problem.
ArcMap.Document.FocusMap.DeleteLayer(layerToRemove);
ArcMap.Document.UpdateContents();
ArcMap.Document.ActiveView.Refresh();
Marshal.FinalReleaseComObject(layerToRemove);
The issue is this: when I try to delete the source file, it gives me IO exception that is the file is in use with arcmap process.
Any help will be appreciated.