If you just debug the program and take a look at your values when the exception occurs, you can learn why it's crashing.
You get the exception because split[5] is an empty string, which cannot be parsed. split[5] is an empty string because of the way you create the string in the first place (bytestring += b + "~"). The resultant string is 1~2~3~4~5~.
You could fix this by either changing the way you create the string, or change the way the string is split.
The latter being:
Code:
string[] split = bytesplit.Split(new[] { '~' }, StringSplitOptions.RemoveEmptyEntries);