/// <summary> /// 自动阅知 /// </summary> /// <param name="resPath"></param> /// <param name="contents"></param> public void Backup() { try { string s = ""; string t = ""; if (DateTime.Now.Month.ToString().Length == 1) { s = "0";//补0 } if (DateTime.Now.Day.ToString().Length == 1) { t = "0";//补0 } string date = DateTime.Now.Year.ToString().Substring(2) + s + DateTime.Now.Month.ToString() + t + DateTime.Now.Day.ToString(); string dirPath = HttpRuntime.AppDomainAppPath + "Log\\AutoBackup\\"; string fileName = "Log" + date + ".txt"; if (!File.Exists(dirPath)) { Directory.CreateDirectory(dirPath); } B_OldToNew backup = new B_OldToNew(); int i=backup.DataTranslate(); if (i > 0) { string contents = "执行自动迁移旧数据 " + DateTime.Now.ToString() + "\r\n"; File.AppendAllText(dirPath + fileName, contents, Encoding.UTF8); } } catch (Exception ex) { WriteLog writelog = new WriteLog(); writelog.WriteErrLog("AutoBackup",DateTime.Now.ToString()+ex.ToString()); throw ex; } }
/// <summary> /// 自动阅知 /// </summary> /// <param name="resPath"></param> /// <param name="contents"></param> public void Backup() { try { string s = ""; string t = ""; if (DateTime.Now.Month.ToString().Length == 1) { s = "0";//补0 } if (DateTime.Now.Day.ToString().Length == 1) { t = "0";//补0 } string date = DateTime.Now.Year.ToString().Substring(2) + s + DateTime.Now.Month.ToString() + t + DateTime.Now.Day.ToString(); string dirPath = HttpRuntime.AppDomainAppPath + "Log\\AutoBackup\\"; string fileName = "Log" + date + ".txt"; if (!File.Exists(dirPath)) { Directory.CreateDirectory(dirPath); } B_OldToNew backup = new B_OldToNew(); int i = backup.DataTranslate(); if (i > 0) { string contents = "执行自动迁移旧数据 " + DateTime.Now.ToString() + "\r\n"; File.AppendAllText(dirPath + fileName, contents, Encoding.UTF8); } } catch (Exception ex) { WriteLog writelog = new WriteLog(); writelog.WriteErrLog("AutoBackup", DateTime.Now.ToString() + ex.ToString()); throw ex; } }