Home > php教程 > php手册 > body text

创建年月日文件

WBOY
Release: 2016-06-06 20:01:29
Original
2229 people have browsed it

/// 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();

        }

    }

 

Related labels:
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template