{"record":{"id":"2a18ae292d8ed171","repo":"BCUninstaller/Bulk-Crap-Uninstaller","slug":"file-name-can-t-be-empty","errorCode":null,"errorMessage":"File name can't be empty.","messagePattern":"File name can't be empty\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"source/KlocTools/Tools/ProcessTools.cs","lineNumber":144,"sourceCode":"        //static readonly char[] pathFilterChars = StringTools.InvalidPathChars.Except(new char[] { '\"' }).ToArray();\n        /// <summary>\n        ///     Attempts to separate filename (or filename with path) from the supplied arguments.\n        /// </summary>\n        /// <param name=\"fullCommand\"></param>\n        /// <returns></returns>\n        /// <exception cref=\"ArgumentNullException\">The value of 'fullCommand' cannot be null. </exception>\n        /// <exception cref=\"ArgumentException\">fullCommand can't be empty</exception>\n        /// <exception cref=\"FormatException\">Filename is in invalid format</exception>\n        public static ProcessStartCommand SeparateArgsFromCommand(string fullCommand)\n        {\n            if (fullCommand == null)\n                throw new ArgumentNullException(nameof(fullCommand));\n\n            // Get rid of whitespaces\n            fullCommand = fullCommand.Trim();\n\n            if (string.IsNullOrEmpty(fullCommand))\n                throw new ArgumentException(Localisation.Error_SeparateArgsFromCommand_Empty, nameof(fullCommand));\n\n            var firstDot = fullCommand.IndexOf('.');\n            if (firstDot < 0)\n                return SeparateNonDottedCommand(fullCommand);\n\n            // Check if the path is in format: ExecutableName C:\\Argname.exe\n            {\n                var pathRoot = fullCommand.IndexOf(\":\\\\\", StringComparison.InvariantCulture);\n                var firstSpace = fullCommand.IndexOf(' ');\n                if (firstSpace >= 0 && firstSpace < pathRoot)\n                {\n                    var filenameBreaker = fullCommand.IndexOfAny(SeparateArgsFromCommandInvalidChars, 0, pathRoot - 1);\n                    if (filenameBreaker < 0)\n                    {\n                        var slashIndex = fullCommand.IndexOf('\\\\');\n                        if (slashIndex >= 0 && slashIndex > pathRoot)\n                        {\n                            var rootSpace = fullCommand.LastIndexOf(' ', pathRoot);","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/BCUninstaller/Bulk-Crap-Uninstaller/blob/608321de98e92297377b1eb69029af55c25504a1/source/KlocTools/Tools/ProcessTools.cs#L126-L162","documentation":"Thrown by ProcessTools.SeparateArgsFromCommand(string fullCommand). After a null check and Trim(), if the command string is empty the method throws ArgumentException(Localisation.Error_SeparateArgsFromCommand_Empty, nameof(fullCommand)) — the localised value is \"File name can't be empty.\". Whitespace-only strings are trimmed to empty and also trigger this.","triggerScenarios":"Calling SeparateArgsFromCommand with an all-whitespace string (e.g. \"   \", \"\\t\") after the explicit null check has already handled null.","commonSituations":"Persisted command-line settings that were saved blank, UI fields the user cleared, or strings read from a file/registry whose value is just spaces.","solutions":["Guard with string.IsNullOrWhiteSpace(fullCommand) at the call site and treat blank as 'no command'.","Trim earlier in the pipeline and skip processing if empty.","Provide a meaningful default command when the configured one is blank."],"exampleFix":"// before\nvar cmd = ProcessTools.SeparateArgsFromCommand(raw); // raw may be \"   \"\n\n// after\nif (string.IsNullOrWhiteSpace(raw)) return null;\nvar cmd = ProcessTools.SeparateArgsFromCommand(raw);","handlingStrategy":"validation","validationCode":"if (string.IsNullOrWhiteSpace(fullCommand)) return null;\nvar cmd = ProcessTools.SeparateArgsFromCommand(fullCommand);","typeGuard":"static bool IsNonEmptyCommand(string s) => !string.IsNullOrWhiteSpace(s);","tryCatchPattern":null,"preventionTips":["Treat blank command strings as 'no command' at the source.","Trim persisted settings on load and reject empty ones.","Provide a default command rather than passing blanks downstream."],"tags":["parsing","command-line","validation","csharp","kloctools"],"backgroundTag":null,"analyzedSha":"608321de98e92297377b1eb69029af55c25504a1","analyzedAt":"2026-08-13T12:17:35.389Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}