string lstrFileFolder = HttpContext.Current.Server.MapPath(Com.Common.m_folderData);
string subFolder = System.DateTime.Today.AddDays(-1).ToString("yyMMdd");
string newFolder = System.DateTime.Today.ToString("yyMMdd");
string path = lstrFileFolder + subFolder;
//判断目录是否存在,存在则改名
if (Directory.Exists(path))
{
Scripting.FileSystemObject fso = new Scripting.FileSystemObjectClass();
fso.GetFolder(path).Name = newFolder;
}
System.IO.Directory.Move("源目录","新目录"); string subFolder = System.DateTime.Today.AddDays(-1).ToString("yyMMdd");
string newFolder = System.DateTime.Today.ToString("yyMMdd");
string path = lstrFileFolder + subFolder;
//判断目录是否存在,存在则改名
if (Directory.Exists(path))
{
Scripting.FileSystemObject fso = new Scripting.FileSystemObjectClass();
fso.GetFolder(path).Name = newFolder;
}
OR
项目->引用 浏览 COM组件 Microsoft Scripting Runtime ,
Scripting.FileSystemObject fso=new Scripting.FileSystemObjectClass();
fso.GetFolder("目录").Name="新目录名";