Home > DeveloperSection > Forums > Creating a new log file each day
Ashish Pandey

Total Post:128

Posted on    November-13-2013 7:23 AM

 C# C# 

 1 Reply(s)
 666  View(s)
Rate this:

I need to create a log file daily in my working business hours.

Basically I need two things:-

1.       How can I create a new log file each day? The log file will be have the name in a format like MMDDYYYY.txt

2.       How can I create it just after midnight in case it is running into all hours of the night?

ezra heywood
ezra heywood

Total Post:145

Posted on    November-13-2013 7:47 AM

Hi Ashish,

I willrecommend something like this:

    string logFile = DateTime.Now.ToString("yyyyMMdd") + ".txt";

    if (!System.IO.File.Exists(logFile))






//append to logFile here...


Don't want to miss updates? Please click the below button!

Follow MindStick