public static void WriteLogJson(string msg) { try { string logPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\Json\\"; //string logPath = Environment.CurrentDirectory + "\\Logs\\"; string logPathFile = logPath + DateTime.Now.ToString("yyyy-MM-dd") + ".txt"; if (!System.IO.Directory.Exists(logPath)) System.IO.Directory.CreateDirectory(logPath); if (!System.IO.File.Exists(logPathFile)) { System.IO.File.Create(logPathFile).Close(); } //对日志加密写入 // msg = ParamUtils.encrypted(Global.Publickey, msg); using (System.IO.StreamWriter sw = System.IO.File.AppendText(logPathFile)) { sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss: ") + msg); sw.Close(); } } catch (Exception ex) { return; } }