If you are writing code to parse command-line arguments, you could use the NuGet package System.CommandLine
.
After adding that package, you can write code like this:
using System;
using System.CommandLine;
namespace Demo
{
static class Program
{
static void Main()
{
string commandLine = "MyDatabase C:\\MyDatabase\\Backup \"C:\\Program Files\\MySQL\\MySQL Server 8.0\\bin\"";
var cmd = new RootCommand();
var result = cmd.Parse(commandLine);
Console.WriteLine($"{result.Tokens.Count} arguments found:");
foreach (var argument in result.Tokens)
{
Console.WriteLine(argument);
}
}
}
}
The output from that program is:
3 arguments found:
Argument: MyDatabase
Argument: C:\MyDatabase\Backup
Argument: C:\Program Files\MySQL\MySQL Server 8.0\bin
This is somewhat of a "sledgehammer to crack a nut", but if you really are parsing command line arguments, System.CommandLine
provides a great deal of functionality beyond just the basic parsing.