# Region Log File
/// <Summary>
/// Proofread and write log files
/// </Summary>
/// <Param name = "checkinformation"> </param>
Public static void writecheckinformationtolog (string checkinformation)
{
Streamwriter Sw = NULL;
Streamwriter swhistory = NULL;
Try
{
Sw = new streamwriter (@ ". \ log.txt", false, encoding. Default );
Swhistory = new streamwriter (". \" + datetime. Now. tow.datestring () + "_log.txt", true, encoding. Default );
Sw. writeline (checkinformation );
Swhistory. writeline (checkinformation );
}
Catch (Exception fileExp)
{
Throw new Exception ("An error occurred while writing information to the log file. System Information: "+ fileExp. Message );
}
Finally
{
Sw. Flush ();
Sw. Close ();
SwHistory. Flush ();
SwHistory. Close ();
}
}
/// <Summary>
/// Read the log file
/// </Summary>
/// <Param name = "checkInformation"> </param>
Public void ReadCheckInformationFromLog ()
{
StreamReader sr = null;
Try
{
Sr = new StreamReader (". \ log.txt", Encoding. Default, true );
Sr. ReadLine ();
}
Catch (Exception fileExp)
{
Throw new Exception ("failed to read log file information. System Information: "+ fileExp. Message );
}
Finally
{
Sr. Close ();
}
}
/// <Summary>
/// Clear the log file
/// </Summary>
Public static void clearlogfile ()
{
Streamwriter Sw = NULL;
// Clear the Current Log File
Try
{
Sw = new streamwriter (@ ". \ log.txt", false, encoding. Default );
Sw. writeline ("");
}
Catch (exception fileexp)
{
Throw new exception ("failed to clear the log file. System Information: "+ fileexp. Message );
}
Finally
{
Sw. Flush ();
Sw. Close ();
}
}
# Endregion