{"record":{"id":"7d0e861e8e95c9ed","repo":"BCUninstaller/Bulk-Crap-Uninstaller","slug":"file-name-cannot-be-empty","errorCode":null,"errorMessage":"File name cannot be empty.","messagePattern":"File name cannot be empty\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"source/UninstallTools/Lists/UninstallList.cs","lineNumber":87,"sourceCode":"                if (uninstallListItem.TestEntry(input) == true)\r\n                {\r\n                    included = true;\r\n                    break;\r\n                }\r\n                included = false;\r\n            }\r\n\r\n            if (!included.HasValue)\r\n                return excluded.HasValue ? true : null;\r\n            return included.Value;\r\n        }\r\n\r\n        public bool Enabled { get; set; } = true;\n\n        public static UninstallList ReadFromFile(string fileName)\n        {\n            if (string.IsNullOrWhiteSpace(fileName))\n                throw new ArgumentException(\"File name cannot be empty.\", nameof(fileName));\n\n            var serializer = new XmlSerializer(typeof (UninstallList));\n            using (var stream = File.OpenRead(fileName))\n            {\n                if (stream.Length == 0)\n                    throw new InvalidDataException(\"The uninstall list file is empty.\");\n\n                try\n                {\n                    return Deserialize(serializer, XmlReader.Create(stream, ReaderSettings));\n                }\n                catch (Exception ex) when (ex is InvalidOperationException or XmlException)\n                {\n                    if (!stream.CanSeek)\n                        throw CreateInvalidDataException(ex);\n\n                    stream.Position = 0;\n                    using var textReader = new StreamReader(stream, Encoding.UTF8, true, 1024, true);","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/BCUninstaller/Bulk-Crap-Uninstaller/blob/608321de98e92297377b1eb69029af55c25504a1/source/UninstallTools/Lists/UninstallList.cs#L69-L105","documentation":"UninstallList.ReadFromFile(string fileName) guards its entry point with string.IsNullOrWhiteSpace(fileName) and throws ArgumentException (param 'fileName') if the supplied path is blank. ReadFromFile opens the file with File.OpenRead, which would otherwise throw an unhelpful ArgumentNullException/ArgumentException from the framework; the explicit check gives a clear, localised contract.","triggerScenarios":"Calling UninstallList.ReadFromFile(null), ReadFromFile(\"\"), or ReadFromFile(\"   \"). Common when the filename comes from a config field, command-line arg, or drag-drop handler that yielded nothing.","commonSituations":"Open-file dialog returns null because the user cancelled and the return value is passed straight through; an MRU list entry with an empty path; a unit test passes null by mistake.","solutions":["Null/whitespace-check fileName before calling ReadFromFile and bail out (e.g. treat user-cancel as a no-op).","Bind the Open button's Enabled state to whether a non-blank path is selected.","Log the source of the empty path (config key, MRU index) to find the upstream producer."],"exampleFix":"// before\nvar list = UninstallList.ReadFromFile(pathFromDialog);\n\n// after\nif (string.IsNullOrWhiteSpace(pathFromDialog))\n    return; // user cancelled or misconfigured\nvar list = UninstallList.ReadFromFile(pathFromDialog);","handlingStrategy":"validation","validationCode":"if (string.IsNullOrWhiteSpace(fileName))\n    throw new InvalidOperationException(\"No file path supplied (user cancelled or misconfigured).\");\nvar list = UninstallList.ReadFromFile(fileName);","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Treat a cancelled file dialog (null result) as a no-op.","Bind the Open action's Enabled state to a non-blank path.","Validate MRU list entries on load and drop blank paths."],"tags":["validation","argument-exception","uninstall-list","io","file-path"],"backgroundTag":null,"analyzedSha":"608321de98e92297377b1eb69029af55c25504a1","analyzedAt":"2026-08-13T12:17:35.389Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}