dotnet/wpf · error · IOException
SR.StorageNotExist
Error message
SR.StorageNotExist
What it means
Thrown by StorageInfo.GetSubStorageInfo when the named child storage does not exist in this storage. Like GetStreamInfo's StreamNotExist, the lookup is strict: a missing sub-storage name throws IOException instead of returning null.
Solutions
- Call StorageExists(name) first and handle the absence branch
- Verify the expected hierarchy of the actual file (enumerate storages) before navigating by fixed names
- Create the sub-storage via CreateStorage if your writer should have produced it
- Fix the storage name/path constant used at the call site
Example fix
// before
var ds = root.GetSubStorageInfo("\u0006DataSpaces");
// after
if (root.StorageExists("\u0006DataSpaces"))
var ds = root.GetSubStorageInfo("\u0006DataSpaces");
else
throw new InvalidDataException("Not a data-spaced compound file"); Defensive patterns
Strategy: validation
Validate before calling
if (!storage.StorageExists(name)) throw new DirectoryNotFoundException($"Sub-storage '{name}' not found"); Type guard
StorageInfo TryGetSubStorage(StorageInfo s, string name) => s.StorageExists(name) ? s.GetSubStorageInfo(name) : null;
Try / catch
try { var ss = storage.GetSubStorageInfo(name); }
catch (IOException ex) { /* missing sub-storage: fall back to creating it or fail gracefully */ } Prevention
- Use StorageExists before strict navigation
- Enumerate existing storages instead of hardcoding expected hierarchy
- Keep storage name constants centralized to avoid typos
When it happens
Trigger: Calling GetSubStorageInfo(name) for a sub-storage that was never created or has been deleted; navigating compound-file structures such as '\u0006DataSpaces' or 'TransformInfo' on files that lack them.
Common situations: Parsing non-XPS/non-RM compound files with hardcoded ODF/XPS paths; opening files saved by third-party OLE writers with a different hierarchy; case-sensitive name mismatches.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- SR.StorageAlreadyExist
- SR.StreamNotExist
- ' ' name is already in use.
- Data space transform stack includes undefined transform…
- DataSpace map entry is not valid.
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/1ff840f184209b6c.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/WindowsBase/System/IO/Packaging/CompoundFile/StorageInfo.cs:454
}
/// <summary>
/// Returns the storage by the passed name.
/// </summary>
/// <param name="name">Name of storage</param>
/// <returns>Reference to the storage</returns>
public StorageInfo GetSubStorageInfo(string name)
{
//Find if this storage exists
StorageInfo storageInfo = new StorageInfo(this, name);
if (storageInfo.InternalExists(name))
{
return storageInfo;
}
else
{
throw new IOException(SR.StorageNotExist);
}
}
/// <summary>
/// Checks if a storage exists by the passed name.
/// </summary>
/// <param name="name">Name of storage</param>
/// <returns>Reference to new storage</returns>
public bool SubStorageExists(string name)
{
StorageInfo storageInfo = new StorageInfo(this, name);
return storageInfo.InternalExists(name);
}
/// <summary>
/// Deletes a storage recursively.
/// </summary>
/// <param name="name">Name of storage</param>View on GitHub (pinned to 81131a70a4)