Home  >  Article  >  php教程  >  创建年月日文件

创建年月日文件

WBOY
WBOYOriginal
2016-06-06 20:01:292227browse

/// summary /// 创建年月日文件 /// /summary /// param name="parPath"根目录/param private void CreateDir(string parPath) { string months = System.DateTime.Now.Month 10 ? "0" + System.DateTime.Now.Month.ToString() : System.DateTime.Now.Month

 

    ///

    /// 创建年月日文件

    ///

    /// 根目录

 

 private void CreateDir(string parPath)

    {

        string months = System.DateTime.Now.Month

        string dates = System.DateTime.Now.Day

 

        DirectoryInfo dyear = new DirectoryInfo(parPath + System.DateTime.Now.Year.ToString());

        DirectoryInfo dmonth = new DirectoryInfo(parPath + System.DateTime.Now.Year.ToString() + "//" + months);

        DirectoryInfo ddate = new DirectoryInfo(parPath + System.DateTime.Now.Year.ToString() + "//" + months + "//" + dates);

 

        if (!dyear.Exists)

        {

            dyear.Create();

            dmonth = dyear.CreateSubdirectory(months);

            ddate = dmonth.CreateSubdirectory(dates);

        }

        if (!dmonth.Exists)

        {

            dmonth.Create();

            ddate = dmonth.CreateSubdirectory(dates);

        }

        if (!ddate.Exists)

        {

            ddate.Create();

        }

    }

 

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:C# 一些简单算法Next article:css样式表的十八种技巧