using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LZBS.Common
{
    public class ReName
    {
        /// <summary>
        /// 根具时间构造一个字符串作为上传的文件名称
        /// </summary>
        /// <returns></returns>
        public static string GetFilename()
        {
            Random rnd = new Random();
            int a = 1000;
            int b = 9999;
            //Year
            string str = DateTime.Now.Year.ToString();
            //Month
            if (DateTime.Now.Month < 10)
            {
                str += "0" + DateTime.Now.Month.ToString();
            }
            else
            {
                str += DateTime.Now.Month.ToString();
            }
            //Day
            if (DateTime.Now.Day < 10)
            {
                str += "0" + DateTime.Now.Day.ToString();
            }
            else
            {
                str += DateTime.Now.Day.ToString();
            }
            //Hour
            if (DateTime.Now.Hour < 10)
            {
                str += "0" + DateTime.Now.Hour.ToString();
            }
            else
            {
                str += DateTime.Now.Hour.ToString();
            }
            //Minute
            if (DateTime.Now.Minute < 10)
            {
                str += "0" + DateTime.Now.Minute.ToString();
            }
            else
            {
                str += DateTime.Now.Minute.ToString();
            }
            //Second
            if (DateTime.Now.Second < 10)
            {
                str += "0" + DateTime.Now.Second.ToString();
            }
            else
            {
                str += DateTime.Now.Second.ToString();
            }
            //获取[a,b]之间的随机数
            str += rnd.Next(a, b).ToString();
            return str;
        }
    }
}
