c# - How to Create Simple but powerful Trial check -
i'm making own type of trial mode , wondering if there way check if time information text file same date.today
?
private void trial() { datetime savenow = datetime.today; datetime expirydate = datetime.today.adddays(30); string filename = system.io.path.combine( environment.getfolderpath(environment.specialfolder.userprofile), "trailexample.txt"); if (!file.exists(filename)) { // write string file. system.io.streamwriter file = new system.io.streamwriter(filename); file.writeline(savenow); file.writeline(expiredate); file.close(); } else if (file.exists(filename)) { var lastline = file.readlines(filename).last(); if (savenow == lastline) // doesn't work of course kinda idea. need with. { messagebox.show("your trial over"); } } }
why not this? don't need text file can modify. have program create hidden file somewhere. doesn't have have in it. checking creation date on hidden file.
else if (file.exists(filename)); { datetime creationdate = file.getcreationtime(file); datecomparisonresult comparedate = creationdate.compareto(savenow); if ((int) comparedate < 0) { messagebox.show("your trial over"); } }
Comments
Post a Comment