if you want to write some success or failed event to log file, then this is the code
first u need to using this namespace
first u need to using this namespace
C#
using System.IO;
FileStream file;
if (File.Exists("FILE_NAME_HERE"))
{
file = new FileStream(
"FILE_NAME_HERE",
FileMode.Append,
FileAccess.Write);
}
else
{
file = new FileStream(
"FILE_NAME_HERE",
FileMode.Create,
FileAccess.Write);
}
// Create a new stream to write to the file
StreamWriter sw = new StreamWriter(file);
// Write a string to the file
sw.WriteLine("module: some module have an error at " + System.DateTime.Now.ToString());
// Close StreamWriter
sw.Close();
// Close file
file.Close();
Comments