这是代码:
private void timer2_Tick(object sender, EventArgs e)
{
timerCount += 1;
TimerCount.Text = TimeSpan.FromSeconds(timerCount).ToString();
TimerCount.Visible = true;
if (File.Exists(Path.Combine(contentDirectory, "msinfo.nfo")))
{
string fileName = Path.Combine(contentDirectory, "msinfo.nfo");
FileInfo f = new FileInfo(fileName);
long s1 = f.Length;
if (f.Length > s1)
{
timer2.Enabled = false;
timer1.Enabled = true;
}
}
}
一旦文件存在,它的大小约为 1.5mb,但几分钟后文件会更新到几乎 23mb。所以我想检查文件是否大于停止 timer2 并启动 timer1 之前的文件。
但是这一行: if (f.Length > s1) 不合逻辑,因为我一直在做 long s1 = f.Length;
我如何检查文件是否比原来的大?