{"record":{"id":"bd024fa5573266b8","repo":"JosefNemec/Playnite","slug":"root-directory-is-not-set-or-does-not-exist","errorCode":null,"errorMessage":"Root directory is not set or does not exist.","messagePattern":"Root directory is not set or does not exist\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"source/Playnite/Common/SafeFileEnumerator.cs","lineNumber":192,"sourceCode":"            : this(new DirectoryInfo(root), pattern, option)\r\n        { }\r\n\r\n        /// <summary>\r\n        /// Create an Enumerator that will scan the file system, skipping directories where access is denied\r\n        /// </summary>\r\n        /// <param name=\"root\">Starting Directory</param>\r\n        /// <param name=\"pattern\">Filter pattern</param>\r\n        /// <param name=\"option\">Recursive or not</param>\r\n        public SafeFileEnumerator(DirectoryInfo root, string pattern, SearchOption option)\r\n            : this(root, pattern, option, new List<Exception>())\r\n        { }\r\n\r\n        // Internal constructor for recursive itterator\r\n        private SafeFileEnumerator(DirectoryInfo root, string pattern, SearchOption option, IList<Exception> errors)\r\n        {\r\n            if (root == null || !root.Exists)\r\n            {\r\n                throw new ArgumentException(\"Root directory is not set or does not exist.\", \"root\");\r\n            }\r\n            this.root = root;\r\n            this.searchOption = option;\r\n            this.pattern = String.IsNullOrEmpty(pattern)\r\n                ? \"*\"\r\n                : pattern;\r\n            this.errors = errors;\r\n        }\r\n\r\n        /// <summary>\r\n        /// Errors captured while parsing the file system.\r\n        /// </summary>\r\n        public Exception[] Errors\r\n        {\r\n            get\r\n            {\r\n                return errors.ToArray();\r\n            }\r","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/JosefNemec/Playnite/blob/5911f4e964e628aa7a69c2030ab35101afa63067/source/Playnite/Common/SafeFileEnumerator.cs#L174-L210","documentation":"Thrown by the SafeFileEnumerator(DirectoryInfo,...) constructor when root is null or its Exists flag is false. It is an ArgumentException on the 'root' parameter, fired before enumeration begins.","triggerScenarios":"Constructing the enumerator with a DirectoryInfo whose path does not exist, was deleted, lives on an unmounted drive, or was passed null; a recursive child whose parent was removed mid-traversal.","commonSituations":"Searching a game library root that was uninstalled/moved; enumerating a removable drive that was ejected; typo in a configured search root; network share offline at scan time.","solutions":["Check root != null && root.Exists before constructing the enumerator.","Verify the drive/share is mounted and reachable.","Wrap construction in try/catch and treat missing roots as empty results."],"exampleFix":"// before\nvar files = new SafeFileEnumerator(new DirectoryInfo(root), pattern, SearchOption.AllDirectories);\n\n// after\nvar di = new DirectoryInfo(root);\nif (!di.Exists)\n{\n    logger.Warn($\"Search root missing: {root}\");\n    return Enumerable.Empty<string>();\n}\nvar files = new SafeFileEnumerator(di, pattern, SearchOption.AllDirectories);","handlingStrategy":"validation","validationCode":"if (root == null || !root.Exists) throw new ArgumentException(\"root missing\");","typeGuard":"static bool IsValidRoot(DirectoryInfo d) => d != null && d.Exists;","tryCatchPattern":"try { return new SafeFileEnumerator(root, pattern, option); }\ncatch (ArgumentException ex) { logger.Warn(ex.Message); return Enumerable.Empty<string>(); }","preventionTips":["Check root != null && root.Exists before constructing.","Confirm the drive/share is mounted before scanning.","Treat missing roots as empty results in batch scans."],"tags":["filesystem","enumeration","validation","playnite"],"backgroundTag":null,"analyzedSha":"5911f4e964e628aa7a69c2030ab35101afa63067","analyzedAt":"2026-08-13T17:38:25.713Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}