0
在方法monitorCallback()中,我將一段時間寫入文本文件。 寫入文件後,我檢查FileInfo文件並打印它。Fileinfo最後一次訪問的毫秒數不會更新
我已經得到了以下結果:
time = 16/08/2009 14:01:46, mili = 307
time = 16/08/2009 14:01:51, mili = 291
time = 16/08/2009 14:01:56, mili = 291
time = 16/08/2009 14:02:01, mili = 291
time = 16/08/2009 14:02:06, mili = 291
time = 16/08/2009 14:02:11, mili = 291
我不明白爲什麼時間的變化,但毫秒爲保持固定
private Timer monitor;
public Window1()
{
InitializeComponent();
monitor = new Timer(monitorCallback, null, 0, 5000);
}
private void monitorCallback(object state)
{
string path = @"C:\Test.txt";
Stream stream = File.OpenWrite(path);
StreamWriter writer = new StreamWriter(stream);
writer.WriteLine(DateTime.Now);
writer.Close();
FileInfo fileInfo = new FileInfo(path);
Dispatcher.Invoke(DispatcherPriority.Normal,
new Action(delegate
{
Debug.WriteLine("time = " + fileInfo.LastWriteTimeUtc + ", mili = " +
fileInfo.LastWriteTimeUtc.Millisecond);
}));
fileInfo = null;
}
似乎無法找到它的任何內容,但也許時間粒度? – 2009-08-16 14:20:55