如果目录不存在就创建

  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));

 

posted on 2016-03-14 08:54  雪原日暮  阅读(440)  评论(0编辑  收藏  举报