C#创建文件夹,往里追字符串。

  /// <summary>写文本日志</summary>
        /// <param name="StrMessage">日志消息</param>
        /// <param name="LogPath">默认指定文件路径</param>
        /// <param name="LogName">日志文本名(不含后缀/默认为当日时间)</param>
        /// <returns>写入成功</returns>

        static public bool WriteFile(String StrMessage, String LogPath = null, String LogName = null)
        {
            if (!string.IsNullOrEmpty(LogPath)) LogFilePath = LogPath;
            LogFileName = (LogName ?? DateTime.Now.ToString("yyyyMMdd")) + @".txt";
            var FullPath = LogFilePath + LogFileName;
            try
            {
                if (!Directory.Exists(LogFilePath)) Directory.CreateDirectory(LogFilePath);
                File.AppendAllText(FullPath, StrMessage, Encoding.UTF8);
            }
            catch (Exception ex)
            {
                //LogHelper.WriteLogEx(typeof(TextFileMethod), ex);
                return false;
            }
            return true;
        }

  这他妈的 失忆了,啥都不会了、标记一下。

posted @ 2015-07-15 18:13  丶神經病  阅读(204)  评论(0编辑  收藏  举报