转载---C# 递归创建文件夹
原博客地址:https://blog.csdn.net/xiao_rory/article/details/8058814
private DirectoryInfo createImgFolder(string filefullpath) { DirectoryInfo dir = null; if (!File.Exists(filefullpath)) { //string dirpath = filefullpath.Substring(0, filefullpath.LastIndexOf('\\')); string[] pathes = filefullpath.Split('\\'); if (pathes.Length > 1) { string path = pathes[0]; for (int i = 1; i < pathes.Length; i++) { path += "\\" + pathes[i]; if (!Directory.Exists(path)) { dir = Directory.CreateDirectory(path); } } } } return dir; }
运行:
参数:D:\workspace-mars\imgserver\IMGPATH\ImgFiles\20190531