Example #1
0
        private static void DeleteWordLog(int limit)
        {
            List <string> loglist = new List <string>();
            DirectoryInfo root    = new DirectoryInfo(AppInfoHelper.GetStatisticsFolder());

            FileInfo[] files = root.GetFiles();
            for (int i = 0; i < files.Length; i++)
            {
                if (Path.GetExtension(files[i].Name) == ".log")
                {
                    string   file = Path.GetFileNameWithoutExtension(files[i].Name);
                    DateTime t    = DateTime.ParseExact(file, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture);
                    if ((DateTime.Now.Date - t).Days > limit)
                    {
                        File.Delete(files[i].FullName);
                    }
                }
            }
        }
Example #2
0
        public static string GetWordLogPath(DateTime dtime)
        {
            string wordLogDirePath = AppInfoHelper.GetStatisticsFolder();
            string month = "", day = "";

            if (dtime.Month < 10)
            {
                month = "0";
            }
            month += dtime.Month.ToString();
            if (dtime.Day < 10)
            {
                day = "0";
            }
            day += dtime.Day.ToString();
            string wordLogFileName = dtime.Year.ToString() + month + day + ".log";
            string wordLogPath     = wordLogDirePath + "\\" + wordLogFileName;

            return(wordLogPath);
        }