log信息添加
This commit is contained in:
commit
3bdeeb028d
4 files changed
+70
-3
No files matched your search
+23
-1
@@ -17,6 +17,7 @@ using System.Runtime.InteropServices;
|
||||
using System.Data.SqlClient;
|
||||
using System.Data;
|
||||
using System.Security.Policy;
|
||||
using System.IO;
|
||||
|
||||
namespace formula_manage
|
||||
{
|
||||
@@ -24,11 +25,32 @@ namespace formula_manage
|
||||
/// Login.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class Login : Window
|
||||
{
|
||||
{
|
||||
|
||||
string logpath = System.Environment.CurrentDirectory + "\\Log";//日志文件目录
|
||||
string logPath = "" + System.Environment.CurrentDirectory + "\\Log\\Log.txt";//日志文件
|
||||
string Log_time = "[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "]:";
|
||||
|
||||
public Login()
|
||||
{
|
||||
WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
||||
InitializeComponent();
|
||||
|
||||
System.IO.DirectoryInfo log = new System.IO.DirectoryInfo(@logpath);//生成日志文件目录
|
||||
if (!File.Exists(logPath))//检查日志文件并写入启动日志
|
||||
{
|
||||
FileStream fs = new FileStream(logPath, FileMode.CreateNew, FileAccess.Write);//创建写入文件
|
||||
StreamWriter wr = new StreamWriter(fs);//创建文件
|
||||
wr.WriteLine(Log_time + "FORMULA_start");
|
||||
wr.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
FileStream fs = new FileStream(logPath, FileMode.Append, FileAccess.Write);
|
||||
StreamWriter wr = new StreamWriter(fs);//创建文件
|
||||
wr.WriteLine(Log_time + "FORMULA_start");
|
||||
wr.Close();
|
||||
}
|
||||
}
|
||||
|
||||
private void Button_Click(object sender, RoutedEventArgs e) //退出按钮事件
|
||||
|
||||
Reference in new issue
Block a user