private static bool DoUpdatedll(string HD, DateTime dtStart, DateTime dtEnd) { string strWrite = ""; try { FileStream fs = new FileStream(Application.StartupPath + "\\Key.dll", FileMode.Create, FileAccess.Write); StreamWriter sw = new StreamWriter(fs); int i = Convert.ToInt32(dtEnd.Subtract(DateTime.Now).TotalDays); if (i == 0) { string str = DateTime.Now.Month.ToString() + "/" + DateTime.Now.Day.ToString() + "/" + DateTime.Now.Year.ToString() + " 11:59:59 PM"; DateTime dt = DateTime.Parse(DateTime.Now.Month.ToString() + "/" + DateTime.Now.Day.ToString() + "/" + DateTime.Now.Year.ToString() + " 11:59:59 PM"); strWrite = HD + "^" + dtStart.ToString() + "^" + dtEnd.ToString() + "^" + dt.ToString(); } else { strWrite = HD + "^" + dtStart.ToString() + "^" + dtEnd.ToString() + "^" + DateTime.Now.ToString(); } sw.WriteLine(Cls_Crypto.Encrypt(strWrite, "MAPLOPTIS93874")); sw.Close(); fs.Close(); sw.Dispose(); fs.Dispose(); return(true); } catch (Exception ex) { return(false); } }
private static bool DoWritedll(string strvalidity) { try { double validity = 0; string strWrite = string.Empty; double.TryParse(strvalidity, out validity); FileStream fs = new FileStream(Application.StartupPath + "\\Key.dll", FileMode.Create, FileAccess.Write); StreamWriter sw = new StreamWriter(fs); if (strvalidity.ToUpper() != "FULL") { strWrite = GetVolumeSerial(Application.StartupPath.Substring(0, 1)) + "^" + DateTime.Now.ToString() + "^" + DateTime.Now.AddDays(validity).ToString() + "^" + DateTime.Now.ToString(); } else { strWrite = GetVolumeSerial(Application.StartupPath.Substring(0, 1)) + "^" + DateTime.Now.ToString() + "^FULL^" + DateTime.Now.ToString(); } sw.WriteLine(Cls_Crypto.Encrypt(strWrite, "MAPLOPTIS93874")); sw.Close(); fs.Close(); sw.Dispose(); fs.Dispose(); return(true); } catch (Exception ex) { return(false); } }
private static string DoReadFirstLine() { string strLine; try { FileStream fs = new FileStream(Application.StartupPath + "\\Key.dll", FileMode.Open, FileAccess.Read); StreamReader sr = new StreamReader(fs); strLine = sr.ReadLine(); sr.Close(); fs.Close(); sr.Dispose(); fs.Dispose(); strLine = Cls_Crypto.Decrypt(strLine, "MAPLOPTIS93874"); return(strLine); } catch (Exception ex) { return(""); } }