I have class that retrieves a date from a certain file. After I make changes to that file I want that class to grab the new date but it keeps showing the original date. I’ve even tried creating a new instance of the class but I get the same results. What am I missing?
EDIT: Simply put, I’m looking to reload the class so it’s cache is replaced.
namespace ProgramUpdater
{
class clsGetFileDates
{
private DateTime eappwDateC = File.GetLastWriteTime(@"c:\files\eappw.exe");
public DateTime EappwDateC
{
get { return eappwDateC; }
set { eappwDateC = value; }
}
}
}
You want to have a look at the FileSystemWatcher class.
http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.aspx
You can set up the FileSystemWatcher to notify you when just the LastWriteTime of your specific file changes, in which case it will call the event handler you specify. Within that event handler you can update your member variable.