f++;
name = BinaryConversion.GetPassword(listBox1.Items[f].ToString());
It could be that line there,it could be a load of your other lines, but you are incrementing f before you use it. So this could be throwing your error as f becomes equal to the count value of listBox1.Items.Count, resulting in your error as it should not be allowed to increase to that value.