Skip to content

Form1.cs | Log

HackTheDev edited this page Aug 5, 2021 · 3 revisions

The following Code is creating a log file. It will contain error messages and other informations. This is the better Log File Text Format in comparison with the Release 2.1.1 where the Log Feature was introduced.

        public void Log(string text, string title)
        {
            try
            {
                if (File.Exists(Application.StartupPath + "\\log.txt"));
                {
                    string prefix = "[" + DateTime.Now + "] ";
                    File.AppendAllText(Application.StartupPath + "\\log.txt", prefix + text + Environment.NewLine);
                }
            } catch { }
        }