I require a way to store the smallest time to replace any existing, but currently what I have tried [below] doesn't work and may sometimes say that 2:38.4 is smaller than 2:20.1.
In the text file
88:88:8
In the form 3 text boxes
timerMin
timerSec
timerMil
Writing into a correct path.
using (TextReader reader = File.OpenText(pathPlayer + player[id].name + "\\time.txt"))
{
string z = reader.ReadLine();
string[] zsplit = z.Split(':');
reader.Close();
fileMin = Convert.ToInt32(timerMinute.Text);
recMin = Convert.ToInt32(zsplit[0]);
if (fileMin < recMin)
{
File.WriteAllText(pathPlayer + player[id].name + "\\time.txt", timerMinute.Text + ":" + timerSecond.Text + ":" + timerMili.Text);
newPersonalRecord = true;
}
else
{
fileSec = Convert.ToInt32(timerSecond.Text);
recSec = Convert.ToInt32(zsplit[1]);
if (fileSec < recSec)
{
File.WriteAllText(pathPlayer + player[id].name + "\\time.txt", timerMinute.Text + ":" + timerSecond.Text + ":" + timerMili.Text);
newPersonalRecord = true;
}
else
{
fileMil = Convert.ToInt32(timerMili.Text);
recMil = Convert.ToInt32(zsplit[1]);
if (fileMil < recMil)
{
File.WriteAllText(pathPlayer + player[id].name + "\\time.txt", timerMinute.Text + ":" + timerSecond.Text + ":" + timerMili.Text);
newPersonalRecord = true;
}
else
{
}
}
}
}
I have been working on this for quite a while and I cannot see where I have gone wrong, and help would be brilliant.
Thanks