Doubts about generating txt log files daily

  • Thread starter Thread starter rta_vix
  • Start date Start date
R

rta_vix

Guest
I have the following problem, I have insertLog method, inside it I'm creating the log folder if it does not exist and I also have another condition that if the log file does not exist, I create the same one. Application that I created will read the files of payment vouchers and insert into the bank, I am only explaining the process, if insert, it generates the log file, every day this service runs from 7am in the morning if I compile today, generates the log, the problem is when it runs tomorrow, it will log the log in the same file as today's date, the right one if it runs the service tomorrow would automatically generate a new log file on tomorrow's date, not on the date today, this is my big problem:


Here is my code:

private static void InsertLog (string row)
{
// Create Log Folder, if it does not exist
if (! Directory.Exists (LogFileLog))
{
Directory.CreateDirectory (LogFileLog);
}

// Create Log File, if it does not exist
string FullPath = LogFileLog + "\\ Banes.txt Proof Processing";
if (! File.Exists (FullPath))
{
using (File.Create (FullPath));
}

// Write to LOG file
using (StreamWriter file = new StreamWriter (FullPath, true))
{
file.WriteLine (line);
file.Close ();
file.Dispose ();
}
}


How could you do to generate daily txt logs for all the files that were processed each day of the week?

Continue reading...
 
Back
Top