{"record":{"id":"e678e6ec91bb7525","repo":"dotnet/wpf","slug":"0-cannot-contain-the-path-delimiter-1","errorCode":null,"errorMessage":"'{0}' cannot contain the path delimiter: '{1}'.","messagePattern":"'(.+?)' cannot contain the path delimiter: '(.+?)'\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/CompoundFile/ContainerUtilities.cs","lineNumber":453,"sourceCode":"            CheckStringAgainstNullAndEmpty(nameString, \"nameString\");\n\n            return (nameString[0] >= '\\x0001'\n                    &&\n                    nameString[0] <= '\\x001F');\n        }\n\n        /// <summary>\n        /// Checks for embedded delimiter in the string (as well as Null and Empty)\n        /// </summary>\n        /// <param name=\"testString\">string to test</param>\n        /// <param name=\"testStringIdentifier\">message for exception</param>\n        internal static void CheckStringForEmbeddedPathSeparator(string testString,\n            string testStringIdentifier)\n        {\n            CheckStringAgainstNullAndEmpty(testString, testStringIdentifier);\n\n            if (testString.Contains(PathSeparator))\n                throw new ArgumentException(\n                    SR.Format(SR.NameCanNotHaveDelimiter,\n                        testStringIdentifier,\n                        PathSeparator), nameof(testString));\n        }\n\n#endif\n    }\n}\n","sourceCodeStart":435,"sourceCodeEnd":462,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/CompoundFile/ContainerUtilities.cs#L435-L462","documentation":"CheckStringForEmbeddedPathSeparator rejects strings containing the compound-file path separator (backslash). Compound-file element names are single path segments; embedded separators would imply a path, which is not allowed within one name.","triggerScenarios":"Calling ConvertStringArrayPathToBackSlashPath or related compound-file APIs with a name string containing '\\'.","commonSituations":"Passing a full path (e.g. \"folder\\file\") where only a single segment name is expected.","solutions":["Pass only the final path segment, not a full path, as the name","Split the path into segments yourself and create intermediate storages for each level","Catch ArgumentException and detect the embedded delimiter to give a clearer message"],"exampleFix":"// before\nCreateStream(\"folder\\\\file.bin\");\n// after\nstring name = Path.GetFileName(\"folder\\\\file.bin\");\nCreateStream(name); // create storages for intermediate segments separately","handlingStrategy":"validation","validationCode":"if (name.Contains('\\\\')) throw new ArgumentException(\"Name must be a single path segment, not a path\");","typeGuard":"static bool IsSingleSegment(string s) => !string.IsNullOrEmpty(s) && !s.Contains('\\\\');","tryCatchPattern":"try { CreateStream(name); } catch (ArgumentException ex) when (ex.Message.Contains(\"delimiter\")) { /* split path and create storages */ }","preventionTips":["Pass Path.GetFileName output, never full paths, as element names","Create intermediate storages explicitly for each path level","Document that compound-file element names are single segments"],"tags":["wpf","packaging","path-separator"],"backgroundTag":"invalid-argument-format","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"}