float time_inval = time2 - time1;
StreamWriter recordtime = new StreamWriter("timeResult.txt",true);//true表示追加的方式写入,这样就可以不覆盖上次的结果。
string str_result=time_inval.ToString();//将float数据转为字符串。
cout++;
string strCount = cout.ToString();
str_result = strCount+":"+str_result+"S";
recordtime.WriteLine(str_result);//将字符串写入文件中
recordtime.Close();