Heim  >  Artikel  >  php教程  >  创建年月日文件

创建年月日文件

WBOY
WBOYOriginal
2016-06-06 20:01:292188Durchsuche

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

        }

    }

 

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Vorheriger Artikel:C# 一些简单算法Nächster Artikel:css样式表的十八种技巧