You can use string.LastIndexOffor this purpose (this is much easier than using string.Split):
static string GetNextFolderName(string folderName)
{
int lastDotPosition = folderName.LastIndexOf('.');
string lastPartOfFolderName = folderName.Substring(lastDotPosition + 1);
int number;
if (int.TryParse(lastPartOfFolderName, out number))
{
number++;
return folderName.Substring(0, lastDotPosition + 1) + number.ToString();
}
else
{
throw new FormatException();
}
}
. , , , Version.TryParse. :
Version.TryParse .NET 4.0. .NET 4.0; ( ) .- , . , . , ,
Version.TryParse , : Version. , , , , , . : 30% , Version.TryParse. - , , , -
Version.TryParse , - . , , , . Version.TryParse, 200%? ; , , , . .
, , , "" . , , - . , , , .