Return to Snippet

Revision: 38725
at January 6, 2011 12:23 by kyrathaba


Initial Code
namespace Kyrathasoft.Dialogs.ErrLogging {

    using System;
    using System.IO;
    using System.Windows.Forms;

    class clsErrLog {

        public clsErrLog() {
            //set default path for error log text file
            errLogPath = Path.GetDirectoryName(Application.ExecutablePath) + "\\errorLog.txt"; 
        }

        public clsErrLog(string errTxt) {
            //set default path for error log text file
            errLogPath = Path.GetDirectoryName(Application.ExecutablePath) + "\\errorLog.txt";
            updateErrorLog(errTxt);
        }

        public clsErrLog(string errTxt, string full_path) {
            errLogPath = full_path;
            updateErrorLog(errTxt);
        }

        private string errLogPath;

        public string ErrLogPath {
            get { return errLogPath; }
            set { errLogPath = value; }
        }

        private void updateErrorLog(string errorText) {
            string msg = Environment.NewLine + Environment.NewLine;
            msg += DateTime.Now.ToString() + Environment.NewLine + errorText;
            File.AppendAllText(errLogPath, msg);
        }

    }

}

Initial URL

                                

Initial Description

                                

Initial Title
Minimist C# error-logging class

Initial Tags

                                

Initial Language
C#