上传图片到指定文件目录,没有则创建目录

 

 protected void Button1_Click(object sender, EventArgs e)
        {
            string driPath = "~/WebApplication3/" + DateTime.Now.Year.ToString() + "/" + DateTime.Now.Month.ToString() + "/";
            string phyPath = Server.MapPath(driPath);
            if (!Directory.Exists(phyPath))
            {
                Directory.CreateDirectory(phyPath);
            }

            this.FileUpload1.SaveAs(phyPath+this.FileUpload1.FileName);
        }

 

posted @ 2012-09-04 16:03  yxyht  阅读(250)  评论(0编辑  收藏  举报