小兰爱学习

转载---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

 

 

 

posted on 2019-06-06 13:12  小兰爱学习  阅读(1346)  评论(0编辑  收藏  举报

导航