如果目录不存在就创建

  if (Directory.Exists(System.Web.HttpContext.Current.Server.MapPath("~/UploadFiles/" + postModel.Pic_Path + "/")) == false)//如果不存在就创建file文件夹
                    {
                        Directory.CreateDirectory(System.Web.HttpContext.Current.Server.MapPath("~/UploadFiles/" + postModel.Pic_Path + "/"));
                    }
                    path_str = System.Web.HttpContext.Current.Server.MapPath(String.Format("/UploadFiles/" + postModel.Pic_Path + "/{0}", postModel.Pic_Name));
原文地址:https://www.cnblogs.com/muxueyuan/p/5274534.html