{"record":{"id":"103da30b7604190f","repo":"dotnet/wpf","slug":"compoundfilereference-malformed-path-encountered","errorCode":null,"errorMessage":"CompoundFileReference: malformed path encountered.","messagePattern":"CompoundFileReference: malformed path encountered\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/CompoundFile/ContainerUtilities.cs","lineNumber":301,"sourceCode":"        ///     Mirror counterpart of ConvertStringArrayPathToBackSlashPath\n        /// </remarks>\n\n        // In theory, parsing strings should be done with regular expressions.\n        // In practice, the RegEx class is too heavyweight for this application.\n\n        // IMPORTANT: When updating this, make sure the counterpart is similarly\n        //  updated.\n        internal static string[] ConvertBackSlashPathToStringArrayPath(string backSlashPath)\n        {\n            // A null string will get a null array\n            if ((null == backSlashPath) || (0 == backSlashPath.Length))\n                return Array.Empty<string>();\n\n            // Reject leading/trailing whitespace\n            if (Char.IsWhiteSpace(backSlashPath[0]) ||\n                Char.IsWhiteSpace(backSlashPath[backSlashPath.Length - 1]))\n            {\n                throw new ArgumentException(SR.MalformedCompoundFilePath);\n            }\n\n            // Build the array\n            string[] splitArray =\n                backSlashPath.Split(PathSeparator);\n\n            // Look for empty strings in the array\n            foreach (string arrayElement in splitArray)\n            {\n                if (0 == arrayElement.Length)\n                    throw new ArgumentException(\n                        SR.PathHasEmptyElement, nameof(backSlashPath));\n            }\n\n            // No empty strings, this array should be fine.\n            return splitArray;\n        }\n","sourceCodeStart":283,"sourceCodeEnd":319,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/CompoundFile/ContainerUtilities.cs#L283-L319","documentation":"ConvertBackSlashPathToStringArrayPath throws this ArgumentException when the backslash path starts or ends with whitespace (or otherwise cannot be represented as a compound-file path element array). The path string is malformed for the compound-file path format.","triggerScenarios":"Thrown at src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/CompoundFile/ContainerUtilities.cs:301 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a well-formed backslash-delimited path (no leading/trailing whitespace, valid characters) to ConvertBackSlashPathToStringArrayPath","Normalize or repair the malformed path before conversion","Catch ArgumentException and treat the path as invalid for the compound file operation"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}