• 把内容生成txt文件


               StringBuilder MailLog = new StringBuilder();

                string logPath = txtFile + str + DateTime.Now.ToString("yyyyMMdd") + ".txt";

                Write(logPath, Context.DateFormat + " - " + message);

    public static void Write(string filePath, string message, bool isNewline = true, Encoding encoding = null, bool append = true)
            {
                encoding = encoding ?? SlEncoding.Default;

                try
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(filePath));
                }
                catch { }

                using (var streamWriter = new StreamWriter(filePath, append, encoding))
                {
                    if (isNewline)
                    {
                        streamWriter.WriteLine(message);
                    }
                    else
                    {
                        streamWriter.Write(message);
                    }
                    streamWriter.Flush();
                }
            }

  • 相关阅读:
    Win32API界面库
    C++模板元编程
    C++模板元编程
    00,跨域的问题
    05,总结——关于用户登录以及注册
    04,Django Form源码阅读
    03,Django的认证系统——auth模块
    用户登录
    用户注册与忘记密码邮箱激活
    DjangoForm表单的基础
  • 原文地址:https://www.cnblogs.com/sk2016/p/6086287.html
Copyright © 2020-2023  润新知