기존의 것을 대체하는 가장 작은 시간을 저장하는 방법이 필요하지만 현재 [아래]가 시도하지 않은 것이 작동하지 않으며 때로는 2 : 38.4가 2보다 작다고 말할 수 있습니다. 20.1. 올바른 경로로 쓰기 형태로 3 텍스트 상자작은 시간을 결정하는 방법 C#
timerMin
timerSec
timerMil
에서 텍스트 파일
88:88:8
에서
. 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
{
}
}
}
}
나는 꽤 오랫동안이 작업을 한 내가 잘못 갈 어디서 볼 수 있고, 도움이 뛰어난 것입니다.
감사
는
Timespan에는 구문 분석 메서드가 있습니다.이 매개 변수를 사용하여 timespans를 구문 분석하고 비교합니다. – Bearcat9425
_ 텍스트 파일 '88 : 88 : 8'_ -에서 TimeSpan으로 구문 분석하지 않습니다. 그게 문자 그대로 야? –