Reputation: 1639
I am developing WPF application
, i want it to run only for 2 months after the installation
.
How to get the installation date once the application installed on the computer.? Is it possible in WPF app.?
Upvotes: 0
Views: 63
Reputation: 2934
Easiest is to check the last write date of the application itself. When installing the application the last write date is set to the current date. In your application you can do something like that (just typed in the browser, might have small typos):
if(File.GetLastWriteTime(Application.ExecutablePath) < DateTime.Now.AddMonths(-2))
{
// Show message and then close the application
}
Be aware that this is not really a safe check. A user can easily change the LastWriteDate of the application and then use it again.
Update:
Changed the file name from "MyApp.exe" to Application.ExecutablePath
Upvotes: 3