{"record":{"id":"1e27638b9af3079e","repo":"stride3d/stride","slug":"path-path-doesn-t-contain-a","errorCode":null,"errorMessage":"path [{path}] doesn't contain a /","messagePattern":"path \\[(.+?)\\] doesn't contain a /","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"sources/core/Stride.Core.IO/VirtualFileSystem.cs","lineNumber":440,"sourceCode":"            return path1 + DirectorySeparatorChar + path2;\n\n        return path1 + path2;\n    }\n\n    /// <summary>\n    /// Gets the parent folder.\n    /// </summary>\n    /// <param name=\"path\">The path.</param>\n    /// <returns>The parent folder.</returns>\n    /// <exception cref=\"System.ArgumentNullException\">path</exception>\n    /// <exception cref=\"System.ArgumentException\">path doesn't contain a /;path</exception>\n    public static string GetParentFolder(string path)\n    {\n        ArgumentNullException.ThrowIfNull(path);\n\n        var lastSlashIndex = LastIndexOfDirectorySeparator(path);\n        if (lastSlashIndex == -1)\n            throw new ArgumentException($\"path [{path}] doesn't contain a /\", nameof(path));\n\n        return path[..lastSlashIndex];\n    }\n\n    /// <summary>\n    /// Gets the file's name with its extension (\"/path/to/file/fileName.ext\"->\"fileName.ext\")\n    /// </summary>\n    /// <param name=\"path\">path containing file's path and name </param>\n    /// <returns>The name of the file with its extension</returns>\n    public static string GetFileName(string path)\n    {\n        ArgumentNullException.ThrowIfNull(path);\n\n        var lastSlashIndex = LastIndexOfDirectorySeparator(path);\n\n        return path[(lastSlashIndex + 1)..];\n    }\n","sourceCodeStart":422,"sourceCodeEnd":458,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core.IO/VirtualFileSystem.cs#L422-L458","documentation":"VirtualFileSystem.GetParentFolder returns the parent portion of a virtual path by locating the last directory separator. If the path contains no '/' at all, LastIndexOfDirectorySeparator returns -1 and this ArgumentException is thrown, since there is no parent folder to compute.","triggerScenarios":"Calling VirtualFileSystem.GetParentFolder with a bare name like \"file.txt\" or a path using backslashes (\"a\\b\\c.txt\") instead of forward slashes, which the virtual file system requires.","commonSituations":"Passing Windows-style local paths into the virtual FS API; concatenating file names without a directory prefix; reading user-supplied paths that may lack a folder component.","solutions":["Ensure the argument is a virtual path containing at least one '/' before calling.","Normalize backslashes to forward slashes (path.Replace('\\\\', '/')) first.","Guard: only call GetParentFolder when path.Contains('/'), otherwise return \"\" or the root yourself.","If the file may be at the root, treat the no-slash case as root parent rather than calling the method."],"exampleFix":"// before\nvar parent = VirtualFileSystem.GetParentFolder(fileName); // throws if no '/'\n// after\nvar parent = fileName.Contains('/') ? VirtualFileSystem.GetParentFolder(fileName) : \"\";","handlingStrategy":"validation","validationCode":"if (path == null || !path.Contains('/'))\n    throw new ArgumentException(\"Virtual path must contain '/'.\", nameof(path));","typeGuard":null,"tryCatchPattern":"try { parent = VirtualFileSystem.GetParentFolder(path); }\ncatch (ArgumentException) { parent = \"\"; /* no folder component */ }","preventionTips":["Normalize backslashes to '/' before any virtual FS call","Never pass bare file names; always use full virtual paths","Centralize path normalization in a helper"],"tags":["filesystem","dotnet","path-parsing"],"backgroundTag":"invalid-argument-format","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}