/// <summary>
/// 添加日志
/// </summary>
/// <param name="LogDire"></param>
/// <param name="logName"></param>
/// <param name="logInfo"></param>
public static string AddLog(string folder, string logName, string logInfo)
{
string rtn = "true";
try
{
string LogDire = AppDomain.CurrentDomain.BaseDirectory.ToString() + "Log\\" + folder + "\\";
if (!Directory.Exists(LogDire))
{
// 不存在,创建
Directory.CreateDirectory(LogDire);
}
string path = LogDire + logName + ".txt";
if (!File.Exists(path))
{
// 不存在,创建
FileStream fs = File.Create(path);
fs.Close();
File.WriteAllText(path, logInfo, Encoding.Default);
}
else
{
File.AppendAllText(path, logInfo, Encoding.Default);
}
}
catch
{
rtn = "fase";
}
return rtn;
}
public static string ReadLog(string LogDire, string logName)
{
string rtn = "";
try
{
if (LogDire == "")
{
LogDire = AppDomain.CurrentDomain.BaseDirectory.ToString() + "rsLog\\";
}
string strFileName = LogDire + "\\" + logName;
if (File.Exists(strFileName))
{
Stream stream1 = new FileStream(strFileName, FileMode.Open);
StreamReader sr = new StreamReader(stream1, Encoding.Default);
rtn = sr.ReadToEnd().ToString();
sr.Close();
stream1.Close();
}
}
catch
{
rtn = "";
}
return rtn;
}