Failed to rename the specified file

Last Published: April 25, 2020

Error Message

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.

Solution or Workaround

Use the SaveAs method instead of MakePermanentAs. Alternatively, release the references to the temporary grid, then call MakePermanentAs.

  • Use the SaveAs method instead of MakePermanentAs:

    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")

  • Release the references to the temporary grid, then call MakePermanentAs:

    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

  • ArcMap 8 x

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options