{"record":{"id":"4a6963bdcb94276f","repo":"SubtitleEdit/subtitleedit","slug":"problem-accessing-riff-file-filename","errorCode":null,"errorMessage":"Problem accessing RIFF file {FileName}","messagePattern":"Problem accessing RIFF file (.+?)","errorType":"exception","errorClass":"RiffParserException","httpStatus":null,"severity":"error","filePath":"src/libse/ContainerFormats/RiffParser.cs","lineNumber":312,"sourceCode":"        /// <param name=\"fourCc\">Output FourCC int</param>\n        /// <param name=\"size\">Output chunk/list size</param>\n        public void ReadTwoInts(out int fourCc, out int size)\n        {\n            try\n            {\n                var buffer = new byte[TwoDWordSize];\n                int readsize = _stream.Read(buffer, 0, TwoDWordSize);\n\n                if (TwoDWordSize != readsize)\n                {\n                    throw new RiffParserException(\"Unable to read. Corrupt RIFF file \" + FileName);\n                }\n                fourCc = RiffDecodeHeader.GetInt(buffer, 0);\n                size = RiffDecodeHeader.GetInt(buffer, 4);\n            }\n            catch (Exception ex)\n            {\n                throw new RiffParserException(\"Problem accessing RIFF file \" + FileName, ex);\n            }\n        }\n\n        /// <summary>\n        /// Non-thread-safe read a single int from the stream\n        /// </summary>\n        /// <param name=\"fourCc\">Output int</param>\n        public void ReadOneInt(out int fourCc)\n        {\n            try\n            {\n                var buffer = new byte[DWordSize];\n                int readsize = _stream.Read(buffer, 0, DWordSize);\n                if (DWordSize != readsize)\n                {\n                    throw new RiffParserException(\"Unable to read. Corrupt RIFF file \" + FileName);\n                }\n                fourCc = RiffDecodeHeader.GetInt(buffer, 0);","sourceCodeStart":294,"sourceCodeEnd":330,"githubUrl":"https://github.com/SubtitleEdit/subtitleedit/blob/17a9f0748781032255db3526b7215d2fb891e3af/src/libse/ContainerFormats/RiffParser.cs#L294-L330","documentation":"The catch-all in ReadTwoInts wraps any exception (IOException, ObjectDisposedException, NotSupportedException from a non-readable stream, etc.) raised during the 8-byte read into a RiffParserException with the 'Problem accessing RIFF file' message and the original as inner. It surfaces stream-level failures with the file name for context.","triggerScenarios":"Underlying stream throws (closed/disposed, network drop, unreadable stream, security/permission denial); disk error during read.","commonSituations":"Network share disconnect mid-read; file deleted or locked by another process during parse; stream wrapped over a closed resource.","solutions":["Inspect the InnerException to find the real I/O cause.","Ensure the stream stays open and readable for the parser's lifetime (do not dispose prematurely).","Open the file with FileShare.ReadWrite to avoid lock contention.","Retry the whole parse once on transient I/O errors."],"exampleFix":"// before\ncatch (Exception ex) { throw new RiffParserException(\"Problem accessing RIFF file \" + FileName, ex); }\n\n// after\ncatch (Exception ex) when (!(ex is RiffParserException)) { throw new RiffParserException($\"Problem accessing RIFF file {FileName} at {_stream?.Position}\", ex); }","handlingStrategy":"try-catch","validationCode":"if (stream == null) throw new ArgumentNullException(nameof(stream));\nif (!stream.CanRead) throw new ArgumentException(\"stream must be readable\", nameof(stream));","typeGuard":null,"tryCatchPattern":"try { rp.ReadTwoInts(out fcc, out size); }\ncatch (RiffParserException ex) { var root = ex.InnerException ?? ex; /* handle I/O root */ }","preventionTips":["Inspect InnerException for the true cause.","Keep the stream open and readable for the parser lifetime."],"tags":["riff","io","exception-wrap","container-format","stream-read"],"backgroundTag":null,"analyzedSha":"17a9f0748781032255db3526b7215d2fb891e3af","analyzedAt":"2026-08-13T18:11:43.374Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}