Yes, there is. If you take the result of the static property Now on the
DateTime type, and then subtract the files last write time, you should get a
TimeSpan instance. Then, you can do the following:
// Assume pobjTimeSpan is the span that holds the difference in time.
// Create a TimeSpan representing 15 minutes.
TimeSpan pobj15Minutes = TimeSpan.FromMinutes(15);
// Now compare to see if the timespan is greater.
if (pobjTimeSpan < pobj15Minutes)
In addition to Nicholas' suggestion, you could also use the TotalMinutes
property of the TimeSpan object.
...
DateTime now = DateTime.Now;
DateTime lastWrite = File.GetLastWriteTime(@"C:\Temp\foo.txt");
TimeSpan interval = now - lastWrite;
if (interval.TotalMinutes >= 15)
{
// do some stuff...
}
...
Regards,
Dan
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.