NLog.Targets.FileTarget.ArchiveByDate C# (CSharp) Method

ArchiveByDate() private method

Archives the fileName using a date style numbering. Archives will be stamped with the prior period (Year, Month, Day, Hour, Minute) datetime. When the number of archive files exceed the obsolete archives are deleted.
private ArchiveByDate ( string fileName, string pattern, LogEventInfo logEvent ) : void
fileName string File name to be archived.
pattern string File name template which contains the numeric pattern to be replaced.
logEvent LogEventInfo Log event that the instance is currently processing.
return void
        private void ArchiveByDate(string fileName, string pattern, LogEventInfo logEvent)
        {
            string dirName = Path.GetDirectoryName(Path.GetFullPath(pattern));
            if (dirName != null)
            {
                DateTime archiveDate = GetArchiveDate(fileName, logEvent);
                string fileNameMask = ReplaceFileNamePattern(pattern, "*");
                string dateFormat = GetArchiveDateFormatString(this.ArchiveDateFormat);
                string archiveFileName = Path.Combine(dirName, fileNameMask.Replace("*", archiveDate.ToString(dateFormat)));
                ArchiveFile(fileName, archiveFileName);
            }

            DeleteOldDateArchives(pattern);
        }