{"record":{"id":"fe9acd1f3ec339b4","repo":"dotnet/wpf","slug":"sr-unabletocreatestorage","errorCode":null,"errorMessage":"SR.UnableToCreateStorage","messagePattern":"SR\\.UnableToCreateStorage","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/WindowsBase/System/IO/Packaging/CompoundFile/StorageInfo.cs","lineNumber":631,"sourceCode":"                // If we don't exist, then ask parent to create us.\n                parentStorage.CreateStorage( core.storageName );\n            }\n            //else if we already exist, we're done here.\n        }\n    }\n\n    private StorageInfo CreateStorage(string name)\n    {\n        // Create new StorageInfo\n        StorageInfo newSubStorage = new StorageInfo( this, name );\n    \n        // Make it real\n        if( !newSubStorage.InternalExists(name) )\n        {\n            /* TBD\n            if( !CU.IsValidCompoundFileName(name))\n            {\n                throw new IOException(\n                        SR.UnableToCreateStorage,\n                        new COMException( \n                            SR.Format(SR.NamedAPIFailure, \"IStorage.CreateStorage\"), \n                            nativeCallErrorCode ));\n                }\n                */\n            // It doesn't already exist, please create.\n            StorageInfoCore newStorage = core.elementInfoCores[ name ] as StorageInfoCore;\n            Invariant.Assert( null != newStorage);\n    \n            int nativeCallErrorCode = core.safeIStorage.CreateStorage(\n                        name, \n                    (GetStat().grfMode & SafeNativeCompoundFileConstants.STGM_READWRITE_Bits)\n                        | SafeNativeCompoundFileConstants.STGM_SHARE_EXCLUSIVE,\n                    0,\n                    0,\n                out newStorage.safeIStorage );\n            if( SafeNativeCompoundFileConstants.S_OK != nativeCallErrorCode )","sourceCodeStart":613,"sourceCodeEnd":649,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/IO/Packaging/CompoundFile/StorageInfo.cs#L613-L649","documentation":"Thrown by StorageInfo.CreateStorage when, after attempting to materialize the new sub-storage through the underlying IStorage, the storage still does not exist internally. It signals that IStorage.CreateStorage did not actually produce the requested element, i.e. the compound file layer failed silently or the name was rejected.","triggerScenarios":"Calling CreateStorage/CreateSubStorage on a storage where the native IStorage.CreateStorage call fails to produce the element (e.g. invalid name characters, corrupted file, read-only underlying file).","commonSituations":"Creating storages with names containing illegal compound-file characters; writing into a file opened from a read-only medium while the failure surfaces through this consistency check; corrupted OLE files.","solutions":["Use a valid compound-file element name (no invalid chars like '/', '\\\\', ':')","Open the underlying file with FileAccess.ReadWrite and appropriate sharing so creation can succeed","Check the file is not corrupted; re-create the compound file if IStorage behaves unexpectedly","Catch IOException from CreateSubStorage and inspect the inner COMException HRESULT for the native error code"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if (!IsValidCompoundFileName(name)) throw new ArgumentException(\"Invalid compound file storage name\", nameof(name));\nif (root.OpenAccess == FileAccess.Read) throw new InvalidOperationException(\"Cannot create storage in read-only root\");","typeGuard":null,"tryCatchPattern":"try { var ss = storage.CreateSubStorage(name); }\ncatch (IOException ex) { /* inspect inner COMException HRESULT */ }","preventionTips":["Use OLE-legal element names","Open roots read-write when creating content","Verify creation succeeded by checking InternalExists after CreateStorage"],"tags":["compound-file","storage","create-failed","io"],"backgroundTag":"file-write-failed","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"}