{"record":{"id":"1ff840f184209b6c","repo":"dotnet/wpf","slug":"sr-storagenotexist","errorCode":null,"errorMessage":"SR.StorageNotExist","messagePattern":"SR\\.StorageNotExist","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/WindowsBase/System/IO/Packaging/CompoundFile/StorageInfo.cs","lineNumber":454,"sourceCode":"    }\n\n    /// <summary>\n    /// Returns the storage by the passed name.\n    /// </summary>\n    /// <param name=\"name\">Name of storage</param>\n    /// <returns>Reference to the storage</returns>\n    public StorageInfo GetSubStorageInfo(string name)\n    {\n        //Find if this storage exists\n        StorageInfo storageInfo = new StorageInfo(this, name);\n\n        if (storageInfo.InternalExists(name))\n        {\n            return storageInfo;\n        }\n        else\n        {\n            throw new IOException(SR.StorageNotExist);\n        }\n    }\n\n     /// <summary>\n    /// Checks if a storage exists by the passed name.\n    /// </summary>\n    /// <param name=\"name\">Name of storage</param>\n    /// <returns>Reference to new storage</returns>\n    public bool SubStorageExists(string name)\n    {\n        StorageInfo storageInfo = new StorageInfo(this, name);\n        return storageInfo.InternalExists(name);\n    }\n    \n    /// <summary>\n    /// Deletes a storage recursively.\n    /// </summary>\n    /// <param name=\"name\">Name of storage</param>","sourceCodeStart":436,"sourceCodeEnd":472,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/IO/Packaging/CompoundFile/StorageInfo.cs#L436-L472","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nvar ds = root.GetSubStorageInfo(\"\\u0006DataSpaces\");\n// after\nif (root.StorageExists(\"\\u0006DataSpaces\"))\n    var ds = root.GetSubStorageInfo(\"\\u0006DataSpaces\");\nelse\n    throw new InvalidDataException(\"Not a data-spaced compound file\");","handlingStrategy":"validation","validationCode":"if (!storage.StorageExists(name)) throw new DirectoryNotFoundException($\"Sub-storage '{name}' not found\");","typeGuard":"StorageInfo TryGetSubStorage(StorageInfo s, string name) => s.StorageExists(name) ? s.GetSubStorageInfo(name) : null;","tryCatchPattern":"try { var ss = storage.GetSubStorageInfo(name); }\ncatch (IOException ex) { /* missing sub-storage: fall back to creating it or fail gracefully */ }","preventionTips":["Use StorageExists before strict navigation","Enumerate existing storages instead of hardcoding expected hierarchy","Keep storage name constants centralized to avoid typos"],"tags":["compound-file","storage","not-found","packaging"],"backgroundTag":"file-not-found","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}