/// <summary>
/// Запись в ЛОГ-файл
/// </summary>
/// <param name="str"></param>
public void WriteToLog(string str, bool doWrite = true)
{
if (doWrite)
{
StreamWriter sw = null;
FileStream fs = null;
try
{
string curDir = AppDomain.CurrentDomain.BaseDirectory;
fs = new FileStream(curDir + "teplouchetlog.pi", FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
sw = new StreamWriter(fs, Encoding.Default);
if (m_vport == null) sw.WriteLine(DateTime.Now.ToString() + ": Unknown port: adress: " + m_address + ": " + str);
else sw.WriteLine(DateTime.Now.ToString() + ": " + m_vport.GetName() + ": adress: " + m_address + ": " + str);
sw.Close();
fs.Close();
}
catch
{
}
finally
{
if (sw != null)
{
sw.Close();
sw = null;
}
if (fs != null)
{
fs.Close();
fs = null;
}
}
}
}