首页 > 其他 > 详细

文件名称 (年4+月2+日2+时2+分2+秒2+毫秒3+8位随机数)

时间:2014-08-13 17:37:06      阅读:272      评论:0      收藏:0      [点我收藏+]

 public  string GeFileName(string type)
    {
        //年4+月2+日2+时2+分2+秒2+毫秒3+8位随机数
        string year = DateTime.Now.Year.ToString();
        string month = DateTime.Now.Month.ToString();
        if (month.Length < 2) { month = "0" + month; }
        string day = DateTime.Now.Day.ToString();
        if (day.Length < 2) { day = "0" + day; }
        string hour = DateTime.Now.Hour.ToString();
        if (hour.Length < 2) { hour = "0" + hour; }
        string minute = DateTime.Now.Minute.ToString();
        if (minute.Length < 2) { minute = "0" + minute; }
        string second = DateTime.Now.Second.ToString();
        if (second.Length < 2) { second = "0" + second; }
        string millisecond = DateTime.Now.Millisecond.ToString("000");
        //8位随机数
        Random rad = new Random();
        int value = rad.Next(10000000, 100000000);
        string fileName = year + month + day + hour + minute +second+ millisecond + value.ToString()+type;
        return fileName;
    }

文件名称 (年4+月2+日2+时2+分2+秒2+毫秒3+8位随机数),布布扣,bubuko.com

文件名称 (年4+月2+日2+时2+分2+秒2+毫秒3+8位随机数)

原文:http://www.cnblogs.com/zhaolijing910/p/3910090.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!