• C# 日常使用整理


    输入千分位格式数字 string.Format("数字格式 {0:n2},", 123456789)

    这个主要和 IFomatProvider  接口有关,NumberFormatInfo numberFomatProvider = new NumberFormatInfo();

     C# 中各种流的操作【参考别人博客】

    https://www.cnblogs.com/JimmyZheng/archive/2012/03/17/2402814.html

    定时执行

    public class MvcApplication : System.Web.HttpApplication
        {
            protected void Application_Start()
            {
                AreaRegistration.RegisterAllAreas();
                FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
                RouteConfig.RegisterRoutes(RouteTable.Routes);
    
                //设置30秒处理一次
                System.Timers.Timer myTimer = new System.Timers.Timer(1000*30);//修改时间间隔
                myTimer.Elapsed += new System.Timers.ElapsedEventHandler(AutoExec);
                myTimer.AutoReset = true;
                myTimer.Enabled = true;
    
            }
            private void AutoExec(object sender, System.Timers.ElapsedEventArgs e) {
                //插入访问日志记录
                Logtxt log = new Logtxt(AppDomain.CurrentDomain.BaseDirectory + @"/log/APILog/Log.txt");
                log.log("**NowTime**:"+Guid.NewGuid().ToString());
            }
        }

     发送邮件

    //from email,to email,主题,邮件内容
                MailMessage mailmessage = new MailMessage("test@centos.com", "886688668@qq.com", "this is a test", "yes!test!");
                mailmessage.Priority = MailPriority.Normal; //邮件优先级
                SmtpClient smtpClient = new SmtpClient("mail.centos.com", 25); //smtp地址以及端口号
                smtpClient.Credentials = new NetworkCredential("test@centos.com", "*******");//smtp用户名密码
                smtpClient.EnableSsl = false; //启用ssl
                smtpClient.Send(mailmessage); //发送邮件
                return Content("发送成功");

     Unix时间戳

                DateTimeOffset BaseTime = new DateTimeOffset(1970, 1, 1, 0, 0, 0, TimeSpan.Zero);
                long unixTime = (long)(DateTime.Now.ToUniversalTime() - BaseTime).TotalSeconds;
                long unixTime3 = (long)(DateTime.Now - BaseTime).TotalSeconds;
    
                DateTime dt = DateTimeOffset.FromUnixTimeSeconds(unixTime).DateTime;
    
                return Content("unixTime:" + unixTime.ToString()+ "--unixTime2:"+ unixTime3.ToString()+"*DateTime:"+ dt.ToString("yyyy-MM-dd HH:mm"));
  • 相关阅读:
    div中子div在firefox ie 水平居中对齐
    Access数据库自定义连接字符串(详细有图百度文档)
    ASP页面乱码
    国内开源asp.netCMS汇总
    sql 2005
    卡巴斯基授权key导入方式方法及其导入key基本原理
    关于SqlServer服务无法启动的症状分析和解决方法
    js下流媒体的在线播放
    用JS+vml作三维报表
    了解嵌入式数据库(sqlite,firebird)
  • 原文地址:https://www.cnblogs.com/life512/p/16054206.html
Copyright © 2020-2023  润新知