62,074
社区成员
发帖
与我相关
我的任务
分享
/// <summary>
/// 创建文件夹
/// </summary>
/// <param name="str">文件夹名数组</param>
public static void Newfolder(string str)
{
string text1 = "";
string[] textArray1 = str.Split(new char[] { '\\' });
for (int num1 = 0; num1 < textArray1.Length; num1++)
{
text1 = text1 + textArray1[num1] + "/";
if (!Directory.Exists(HttpContext.Current.Server.MapPath(text1)))
{
Directory.CreateDirectory(HttpContext.Current.Server.MapPath(text1));
}
}
}
string fileUrlPath = "~/FileUpload/";//生成的文件夹要保存的位置
string time = DateTime.Now.ToString("yyyyMMdd");
string path = fileUrlPath + time + "/"; //完整路径
if (!Directory.Exists(Server.MapPath(path)))
{
Directory.CreateDirectory(Server.MapPath(path)); //创建文件夹
}