{"record":{"id":"451bf4f74213c4b5","repo":"dotnet/wpf","slug":"path-string-cannot-include-an-empty-element","errorCode":null,"errorMessage":"Path string cannot include an empty element.","messagePattern":"Path string cannot include an empty element\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/CompoundFile/ContainerUtilities.cs","lineNumber":312,"sourceCode":"            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\n        /// <summary>\n        ///     Concatenates the names in an array of strings into a backslash-\n        /// delimited string.\n        ///\n        ///  string[] { \"images\", \"button.jpg\" } -> string \"images\\button.jpg\"\n        ///\n        /// </summary>\n        /// <param name=\"arrayPath\">\n        ///     String array of names\n        /// </param>\n        /// <returns>","sourceCodeStart":294,"sourceCodeEnd":330,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/CompoundFile/ContainerUtilities.cs#L294-L330","documentation":"ConvertBackSlashPathToStringArrayPath throws this ArgumentException when splitting the backslash path on separators yields an empty element — i.e. the path contains consecutive backslashes or a trailing separator. Empty path components are not valid in compound-file paths.","triggerScenarios":"Thrown at src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/CompoundFile/ContainerUtilities.cs:312 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Remove empty path segments (consecutive backslashes) from the path before conversion","Ensure paths like 'dir\\sub\\' are normalized to avoid empty elements","Catch ArgumentException and surface a malformed-path error to the caller"],"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"}