ERROR
This error occurs when using the MakePermanentAs method to make a temporary output from a spatial analyst function into a permanent raster (grid):“Failed to rename the specified file”
This happens when the permanent output file specified is a grid raster dataset and is in the same directory as the temporary output. MakePermanentAs does not make another copy of the grid, instead, it renames the temporary grid. If the references to the grid are not released before calling MakePermanentAs, an error will occur.
Code:
Dim pRBC As IRasterBandCollection
Set pRBC = pOutGDS '-- pOutGDS is a IGeoDataset generated from a SA function
Dim pDS As IGeoDataset
Set pDS = pRBC.SaveAs("test2", pWs, "TIFF")
Code:
Public Function MakePermanentAs(pSAOutRaster As IRaster)
'-- pSAOutRaster is a Raster Object from a Spatial operation
Dim pRasBC As IRasterBandCollection
Set pRasBC = pSAOutRaster
'-- Get the dataset from the first band
Dim pOutDS As IRasterDataset
Set pOutDS = pRasBC.Item(0).RasterDataset
'-- QI the dataset for ITemporaryDataset
Dim pTemp As ITemporaryDataset
Set pTemp = pOutDS
'-- Release the raster before making the dataset permanent
Set pRasBC = Nothing
Set pOutGDS = Nothing
Dim pDS As IDataset
Set pDS = pTemp.MakePermanentAs("c:\temp\outgrd", Nothing, "GRID")
End Function
Article ID:000003689
Get help from ArcGIS experts
Download the Esri Support App