| Previous | Next |
| STG_E_INVALIDHEADER | STG_E_UNKNOWN |
STG_E_INVALIDNAME
Internal names are not normal file paths
STG_E_INVALIDNAME concerns the name of a storage or stream inside a Structured Storage container. It does not necessarily mean that the Windows filename is invalid. The CFB directory stores element names with its own rules, and the Structured Storage APIs impose restrictions on names supplied to methods such as IStorage::CreateStorage and IStorage::OpenStorage.
Microsoft documents a maximum of 31 characters for a newly created storage name and reserves control characters U+0000 through U+001F when they occur as the first character of a compound-file stream or storage name. Problems also occur when a producer and consumer use different Unicode normalization, truncate names inconsistently, or accidentally pass an external filesystem path where an internal element name is required.
What to validate
- Log the exact Unicode name, character count, and method receiving it; do not rely on a display string that hides control characters.
- Keep external filenames and internal CFB element names as separate concepts in the code and data model.
- Define a deterministic mapping for user-provided names, including collision handling after truncation.
- Inspect a known-good container to confirm the producer’s expected stream names before changing a parser or migration tool.
References
- Microsoft: IStorage::CreateStorage naming rules
- Microsoft: MS-CFB specification
- libolecf compound-file documentation
Looking for a different code? Search another status or error code.