#region 定时删除目录文件 /// <summary> /// 定时删除目录文件
/// northeasttycoon /// </summary> /// <param name="strParaTime">根据参数删除定义为int类型变量为宜</param> public void DeleteRecFiles(string strParaTime) {
// 获得文件路径 string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "BackUpMessageInfo");
// 获得删除天数 DateTime _dtNow = DateTime.Parse(DateTime.Today.ToString("yyyy-MM-dd")).AddDays(-Convert.ToInt32(strParaTime)); // 时间是可配置 // DateTime _dtNow = DateTime.Parse("2016-7-26"); if (Directory.Exists(path)) { DirectoryInfo _DirectoryInfo = new DirectoryInfo(path); DirectoryInfo[] _DicInfoList = _DirectoryInfo.GetDirectories(); foreach (DirectoryInfo dicInfo in _DicInfoList) { int iNayibuTime = DateTime.Compare(_dtNow, DateTime.Parse(dicInfo.Name)); if (0 < iNayibuTime) { dicInfo.Delete(true); } } } } #endregion