What does HRESULT 0x80030050 (STG_E_FILEALREADYEXISTS) mean?

 
Previous Next
STG_E_LOCKVIOLATION STG_E_INVALIDPARAMETER

STG_E_FILEALREADYEXISTS

Why the existing object matters

STG_E_FILEALREADYEXISTS is often returned when an application attempts to create a storage or stream whose name is already present and the requested mode includes STGM_FAILIFTHERE. In a compound file, this may refer to an internal storage element rather than a separate file visible in Explorer. The outer document can therefore be present and healthy while creation of one named child object is intentionally refused.

The correct fix depends on the intended semantics. A configuration writer may need to fail because replacing an existing stream would destroy data. A cache builder may instead need an explicit update or replace path. Treating every existing element as disposable is risky in compound documents that contain multiple independent streams.

Design and diagnosis

  • Record the exact element name and the STGM_* flags used for creation.
  • Decide explicitly whether the operation should create-only, open-and-update, replace, or version the existing object.
  • For user documents, inspect the storage tree before overwriting; a similarly named stream can belong to a different feature or producer.
  • Use transaction/commit handling so a failed update does not leave a partially replaced container.

References


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