private long GetSumToOutputFile(string outputFilename, bool appendMessagesIfFileExists,
                                        bool showMessageType, bool showApplicationName, bool showMachineName,
                                        long minNum, long maxNum, long outputEveryInterval, bool showDateTime)
        {
            long        sum     = 0;
            TextLogFile logfile = null;

            try
            {
                logfile = new TextLogFile(outputFilename);
                logfile.ShowMessageType = showMessageType;
                if (showApplicationName)
                {
                    logfile.ApplicationName = "TestprogMessageLogs";
                }
                if (showMachineName)
                {
                    logfile.MachineName = Environment.MachineName;
                }
                if (File.Exists(outputFilename))
                {
                    if (appendMessagesIfFileExists == false)
                    {
                        logfile.TruncateFile();
                    }
                }

                logfile.ShowDatetime = showDateTime;
                for (long i = minNum; i <= maxNum; i++)
                {
                    sum += i;
                    if ((i % outputEveryInterval) == 0 || i == maxNum)
                    {
                        _msg.Length = 0;
                        _msg.Append("Sum calculated to " + i.ToString("#,##0"));
                        _msg.Append(" = ");
                        _msg.Append(sum.ToString("#,##0"));
                        logfile.WriteLine(_msg.ToString(), TextLogFile.LogMessageType.Information);
                    }
                }
                if (showMessageType)
                {
                    logfile.WriteLine("This is a test warning message.", TextLogFile.LogMessageType.Warning);
                    logfile.WriteLine("This is a test error message.", TextLogFile.LogMessageType.Error);
                }
            }
            catch (System.Exception ex)
            {
                _msg.Length = 0;
                _msg.Append(AppGlobals.AppMessages.FormatErrorMessage(ex));
                logfile.WriteLine(_msg.ToString(), TextLogFile.LogMessageType.Error);
                WriteMessageToLog(_msg.ToString());
                AppMessages.DisplayErrorMessage(_msg.ToString());
            }
            finally
            {
                ;
            }

            return(sum);
        }