Простая арифметика должна делать:
string name = file.Substring(startIndex - 1, stopIndex - startIndex + 1);
В вашем случае
name1 = file.Substring( 6 - 1, 12 - 6 + 1);
name2 = file.Substring(16 - 1, 22 - 16 + 1);
name3 = file.Substring(33 - 1, 36 - 33 + 1);
name4 = file.Substring(53 - 1, 55 - 53 + 1);
Возможно, вы захотите реализовать метод расширения для этого:
public static partial class StringExtensions {
public static string FromTo(this string value, int fromIndex, int toIndex) {
if (null == value)
throw new ArgumentNullException(nameof(value));
else if (fromIndex < 1 || fromIndex > value.Length)
throw new ArgumentOutOfRangeException(nameof(fromIndex));
else if (toIndex < 1 || toIndex > value.Length || toIndex < fromIndex)
throw new ArgumentOutOfRangeException(nameof(toIndex));
return value.Substring(fromIndex - 1, toIndex - fromIndex + 1);
}
}
А потом просто, как
name1 = file.FromTo( 6, 12);
name2 = file.FromTo(16, 22);
name3 = file.FromTo(33, 36);
name4 = file.FromTo(53, 55);