using System;
|
using System.IO;
|
|
namespace Authorization.Tools
|
{
|
public class Common
|
{
|
static object o = new object();
|
public static void SaveToLicense(string msg, string adress, string dir_name)
|
{
|
System.IO.FileStream FS = null;
|
System.IO.StreamWriter SW = null;
|
lock (o)
|
{
|
try
|
{
|
string startupPath = AppDomain.CurrentDomain.BaseDirectory;
|
string datefolder = Path.Combine(startupPath, dir_name, adress, DateTime.Now.ToString("yyyy-MM-dd"));
|
if (!Directory.Exists(datefolder))
|
{
|
try
|
{
|
Directory.CreateDirectory(datefolder);
|
}
|
catch (Exception)
|
{
|
throw;
|
}
|
}
|
string filepath = Path.Combine(startupPath, dir_name, adress, DateTime.Now.ToString("yyyy-MM-dd"), "license.cpy");
|
if (!File.Exists(filepath))
|
{
|
try
|
{
|
FS = File.Create(filepath);
|
}
|
catch (Exception)
|
{
|
throw;
|
}
|
finally
|
{
|
FS.Close();
|
FS.Dispose();
|
}
|
FS = new System.IO.FileStream(filepath, System.IO.FileMode.Append, System.IO.FileAccess.Write);
|
}
|
else
|
{
|
FS = new System.IO.FileStream(filepath, System.IO.FileMode.Create, System.IO.FileAccess.Write);
|
}
|
|
SW = new System.IO.StreamWriter(FS);
|
SW.Write(msg);
|
SW.Flush();
|
}
|
catch
|
{
|
throw;
|
}
|
finally
|
{
|
if (SW != null)
|
{
|
SW.Close();
|
SW.Dispose();
|
}
|
if (FS != null)
|
{
|
FS.Close();
|
FS.Dispose();
|
}
|
}
|
}
|
}
|
}
|
}
|