If you can, just use Path.GetFileNameWithoutExtension
Returns the file name of the specified path string without the extension.
Path.GetFileNameWithoutExtension("asdasdasd.asdas.adas.asdasdasdasd.edasdasd");
With one line of code you can get the same result.
If you want to create one by yourself, why not just use this?
int index = a.LastIndexOf('.');
b = index == -1 ? a : a.Substring(0, index);
P.S Special thanks to @Anthony and @CompuChip to point me out some mistake i done, bad day maybe.
You take everything which comes from 0 (the start) to the last dot which means the start of the extension
a
contain a path? \$\endgroup\$