{"record":{"id":"351c256714bc50b4","repo":"dotnet/wpf","slug":"sr-streamnotexist","errorCode":null,"errorMessage":"SR.StreamNotExist","messagePattern":"SR\\.StreamNotExist","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/WindowsBase/System/IO/Packaging/CompoundFile/StorageInfo.cs","lineNumber":384,"sourceCode":"    /// Returns the streaminfo by the passed name.\n    /// </summary>\n    /// <param name=\"name\">Name of stream</param>\n    /// <returns>Reference to the stream</returns>\n    public StreamInfo GetStreamInfo(string name)\n    {\n        CheckDisposedStatus();\n\n        //check the arguments\n        ArgumentNullException.ThrowIfNull(name);\n\n        StreamInfo streamInfo = new StreamInfo(this, name);\n        if (streamInfo.InternalExists())\n        {\n            return streamInfo;\n        }\n        else\n        {\n            throw new IOException(SR.StreamNotExist);\n        }\n    }\n\n    /// <summary>\n    /// Check if the stream exists.\n    /// </summary>\n    /// <param name=\"name\">Name of stream</param>\n    /// <returns>True if exists, False if not</returns>\n    public bool StreamExists(string name)\n    {\n        CheckDisposedStatus();\n        \n        bool streamExists = false;\n\n        StreamInfo streamInfo = new StreamInfo(this, name);\n        streamExists = streamInfo.InternalExists();\n\n        return streamExists;","sourceCodeStart":366,"sourceCodeEnd":402,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/IO/Packaging/CompoundFile/StorageInfo.cs#L366-L402","documentation":"Thrown by StorageInfo.GetStreamInfo when the requested named stream does not exist in this storage. It is the strict variant: unlike TryGetStreamInfo-style paths, an absent stream name is treated as a hard failure with IOException rather than returning null.","triggerScenarios":"Calling GetStreamInfo(streamName) for a stream name that was never created in the storage, or after the stream was deleted via DestroyElement/Delete.","commonSituations":"Reading well-known compound-file streams ('\\u0006DataSpaces/DataSpaceMap', version stream, content stream) from a file that is not actually an XPS/RM package or has a different internal layout; typos in stream names including the '\\u0006'-prefixed internal names.","solutions":["Check StreamExists(streamName) before calling GetStreamInfo","Confirm the file is a valid OLE compound file with the expected package layout (e.g. open with EncryptedPackageEnvelope/XpsDocument rather than raw StorageInfo)","Fix the stream name; note internal streams start with the '\\u0006' prefix","Create the stream first via CreateStream if your code is responsible for populating it"],"exampleFix":"// before\nvar si = storage.GetStreamInfo(versionStreamName);\n// after\nif (storage.StreamExists(versionStreamName))\n{\n    var si = storage.GetStreamInfo(versionStreamName);\n}\nelse\n{\n    throw new InvalidDataException($\"Stream '{versionStreamName}' missing; not a valid package\");\n}","handlingStrategy":"validation","validationCode":"if (!storage.StreamExists(streamName)) throw new FileNotFoundException($\"Stream '{streamName}' not found in storage\");","typeGuard":"StreamInfo TryGetStream(StorageInfo s, string name) => s.StreamExists(name) ? s.GetStreamInfo(name) : null;","tryCatchPattern":"try { var si = storage.GetStreamInfo(name); }\ncatch (IOException ex) { /* treat as missing stream; log name and file */ }","preventionTips":["Prefer StreamExists checks before strict GetStreamInfo lookups","Remember internal streams are '\\u0006'-prefixed","Verify the file actually is the expected package format before reading fixed stream names"],"tags":["compound-file","stream","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"}