{"record":{"id":"ddbaabaf0ddbbf33","repo":"LykosAI/StabilityMatrix","slug":"source-directory-not-found-dir-fullname","errorCode":null,"errorMessage":"Source directory not found: {dir.FullName}","messagePattern":"Source directory not found: (.+?)","errorType":"exception","errorClass":"DirectoryNotFoundException","httpStatus":null,"severity":"error","filePath":"StabilityMatrix.Core/Helper/Utilities.cs","lineNumber":31,"sourceCode":"        var version = assembly.GetName().Version;\n        return version == null\n            ? \"(Unknown)\"\n            : $\"{version.Major}.{version.Minor}.{version.Build}.{version.Revision}\";\n    }\n\n    public static void CopyDirectory(\n        string sourceDir,\n        string destinationDir,\n        bool recursive,\n        bool includeReparsePoints = false\n    )\n    {\n        // Get information about the source directory\n        var dir = new DirectoryInfo(sourceDir);\n\n        // Check if the source directory exists\n        if (!dir.Exists)\n            throw new DirectoryNotFoundException($\"Source directory not found: {dir.FullName}\");\n\n        // Cache directories before we start copying\n        var dirs = includeReparsePoints\n            ? dir.GetDirectories()\n            : dir.GetDirectories().Where(d => !d.Attributes.HasFlag(FileAttributes.ReparsePoint));\n\n        // Create the destination directory\n        Directory.CreateDirectory(destinationDir);\n\n        // Get the files in the source directory and copy to the destination directory\n        foreach (var file in dir.GetFiles())\n        {\n            var targetFilePath = Path.Combine(destinationDir, file.Name);\n            if (file.FullName == targetFilePath)\n                continue;\n            file.CopyTo(targetFilePath, true);\n        }\n","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/LykosAI/StabilityMatrix/blob/af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002/StabilityMatrix.Core/Helper/Utilities.cs#L13-L49","documentation":"Utilities.CopyDirectory recursively copies a directory tree. It first wraps sourceDir in a DirectoryInfo and throws DirectoryNotFoundException when the source does not exist, so the copy never starts on a bogus root. The message includes the resolved full path for diagnosis.","triggerScenarios":"Calling CopyDirectory(sourceDir, destDir, ...) where sourceDir does not exist — unmounted drive, wrong base path, or directory deleted before the copy.","commonSituations":"Copying shared-model folders whose location was moved; backup/restore scripts running before the source was created; misconfigured settings pointing at a nonexistent directory.","solutions":["Verify Directory.Exists(sourceDir) before calling CopyDirectory","Correct the configured/source path (log the full resolved path)","Create the source directory first if it is expected to be initialized elsewhere","Catch DirectoryNotFoundException and show a user-facing 'source folder missing' message"],"exampleFix":"// before\nUtilities.CopyDirectory(srcDir, dstDir);\n// after\nif (!Directory.Exists(srcDir))\n    throw new DirectoryNotFoundException($\"Source missing: {srcDir}\");\nUtilities.CopyDirectory(srcDir, dstDir);","handlingStrategy":"validation","validationCode":"if (!Directory.Exists(sourceDir))\n    throw new DirectoryNotFoundException($\"Source directory not found: {Path.GetFullPath(sourceDir)}\");","typeGuard":"static bool IsExistingDir(string? p) => !string.IsNullOrWhiteSpace(p) && Directory.Exists(p);","tryCatchPattern":"try { Utilities.CopyDirectory(src, dst, true); }\ncatch (DirectoryNotFoundException ex) { MessageBox.Show($\"Source folder missing: {ex.Message}\"); }","preventionTips":["Validate configured source paths at startup","Resolve and log full paths before copying","Create source directories during setup/init flows","Guard against unmounted drives/network shares before bulk copies"],"tags":["csharp","file-io","directory"],"backgroundTag":"directory-not-found","analyzedSha":"af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002","analyzedAt":"2026-09-12T19:02:43.389Z","contentChangedAt":"2026-09-12T19:02:43.389Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}