Пример #1
0
        private void LogFile(String str)
        {
            // Create a writer and open the file:
            ///string logfile = WebConfigurationManager.AppSettings["SystemLog"].ToString() ;
            StreamWriter log;

            if (!File.Exists("logfile.txt"))
            {
                log = new StreamWriter("logfile.txt");
            }
            else
            {
                log = File.AppendText("logfile.txt");
            }
            // Write to the file:
            log.WriteLine(DateTime.Now);
            log.WriteLine(str);
            log.WriteLine();
            // Close the stream:
            log.Close();
            //end of write
        }