如何检测用户是否删除了文件?
问题描述:
大家好,我已经在c#.net上制作了试用版windows应用程序。试用信息文件存储在系统文件夹中。现在我想让该文件无法删除,因为如果它被删除,那么用户将永远使用我的应用程序。有没有办法做到这一点?或者如何在应用程序第二次启动时检测用户是否删除了该文件?
Hi, I have made a trial version windows application in c#.net. The trial info file is stored in the system folder. Now i want to make that file undeletable because if it is deleted then the user will use my application forever. So is there any way to do this? or how can i detect if the user has deleted that file when application start second time?
答
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
if (File.Exist(Path))
{
.... Checking File Data....
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}