欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  php教程

创建年月日文件

程序员文章站 2022-04-28 17:27:03
...

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

}

}