/// <Summary>
/// Generate doc-pdf log
/// </Summary>
/// <Paramname = "item"> operation item name </param>
/// <Paramname = "errorContent"> error message </param>
/// <Paramname = "FileName_Prefix"> file name prefix (full name of the time combination) </param>
Public static void savegeneraldoc1_logfiles (string item, stringerrorContent, string FileName_Prefix)
{
StreamWriter sw = null;
DateTime date = DateTime. Now;
String FileName = string. Empty;
Try
{
If (HttpContext. Current = null)
{
FileName = HttpRuntime. AppDomainAppPath + "/Logs/GeneralDocPdf/" + FileName_Prefix + "_" + date. Month + date. Day + ". log ";
}
Else
{
FileName = HttpContext. Current. Server. MapPath ("~ /Logs/GeneralDocPdf/"+ FileName_Prefix +" _ "+ date. Month + date. Day +". log ");
}
# Region check whether the log directory exists
String forderPathStr = null;
If (HttpContext. Current = null)
{
ForderPathStr = HttpRuntime. AppDomainAppPath + "/Logs/GeneralDocPdf ";
}
Else
{
ForderPathStr = HttpContext. Current. Server. MapPath ("~ /Logs/GeneralDocPdf ");
}
If (! Directory. Exists (forderPathStr ))
{
Directory. CreateDirectory (forderPathStr );
}
If (! File. Exists (FileName ))
{
Sw = File. CreateText (FileName); // if the File does not exist, create and add the content.
}
Else
{
Sw = File. AppendText (FileName); // If the log File already exists, content is appended to the File
}
# Endregion
Sw. WriteLine (item );
Sw. WriteLine (errorContent); // write row
Sw. WriteLine ("[Time]" + System. DateTime. Now );
Sw. writeLine when there are already too many other than too many ");
Sw. Flush ();
}
Finally
{
If (sw! = Null)
Sw. Close ();
}
}