What does Windows error code 1175 (ERROR_UNABLE_TO_REMOVE_REPLACED) mean?

 
Previous Next
ERROR_NO_VOLUME_ID ERROR_UNABLE_TO_MOVE_REPLACEMENT

ERROR_UNABLE_TO_REMOVE_REPLACED

The original file could not be removed during ReplaceFile.

ERROR_UNABLE_TO_REMOVE_REPLACED is error 1175 (0x497). It is one of the documented partial-failure results from ReplaceFile. Microsoft specifies that the replaced file could not be deleted and that the replaced and replacement files retain their original names.

Known post-failure state

This result is valuable because it describes the namespace outcome: the target still exists under its original name, and the candidate replacement also still exists under its original name. The application must not report the new data as committed.

Likely causes

  • another process has an incompatible open handle to the target
  • the caller lacks delete access on the file and delete-child access on the parent directory
  • security, antivirus, indexing, or backup software races with the replacement
  • the target changes between preparation and commit
  • directory or file attributes and ACLs do not permit removal

Evidence to preserve immediately

  • replaced, replacement, and optional backup paths
  • file IDs, sizes, hashes, timestamps, attributes, and security descriptors
  • ReplaceFile flags and caller identity
  • open-handle or sharing information for the target
  • whether all three paths resolve to the same volume as required

Use file IDs in addition to paths. A concurrent rename can make a path-based log describe a different file by the time support staff inspect it.

Recovery sequence

  • leave both files intact until their contents and identities are verified
  • close application-owned handles and identify external sharing conflicts
  • revalidate that the original target is still the version the replacement was based on
  • retry only after the delete obstacle is removed
  • clean the temporary replacement only after deciding that it is not needed

Do not fall back immediately to deleting the target and renaming the replacement; that can discard metadata, break the atomicity expectation, or overwrite a file modified by another process.

Developer guidance

Model file replacement as a commit operation with explicit states. Write and flush the candidate, record the expected target identity, call ReplaceFile, and publish success only after the API succeeds. On 1175, retain enough information to retry or recover safely after restart.

Difference among the three ReplaceFile-specific errors

For 1175, both files keep their original names. ERROR_UNABLE_TO_MOVE_REPLACEMENT describes failure renaming the replacement and has a different state depending on whether a backup name was supplied. ERROR_UNABLE_TO_MOVE_REPLACEMENT_2 can leave the original under a different name while the replacement inherits streams and attributes. The exact code determines recovery.

Example

An editor writes document.tmp and calls ReplaceFile for document.dat. A scanner holds the target without delete sharing, so 1175 is returned. The editor keeps both files, records their IDs and hashes, waits for the conflicting handle to close, verifies that the target has not changed, and then retries the commit.

References


Looking for a different code? Search another status or error code.