C#フォルダが存在するか否かを判断し、フォルダを作成


protected void Button1_Click(object sender, EventArgs e)
     {
 
         if (Directory.Exists(Server.MapPath("~/upimg/hufu")) == false)//        file   
         {
             Directory.CreateDirectory(Server.MapPath("~/upimg/hufu"));
         }
 
         //Directory.Delete(Server.MapPath("~/upimg/hufu"), true);//               ,      
 
         //       
 
         if (File.Exists(Server.MapPath("~/upimg/Data.html")))
         {
             Response.Write("Yes");
 
             //    
 
         }
 
         else
         {
             Response.Write("No");
             //     
             File.Create(MapPath("~/upimg/Data.html"));//     
 
         }
 
         string name = GetFiles.FileName;//          
         string size = GetFiles.PostedFile.ContentLength.ToString();//          
         string type = GetFiles.PostedFile.ContentType;//        MIME
         string postfix = name.Substring(name.LastIndexOf(".") + 1);//          
         string ipath = Server.MapPath("upimg") +"\\"+ name;//         
         string fpath = Server.MapPath("upfile") + "\\" + name;
         string dpath = "upimg\\" + name;//            
 
         ShowPic.Visible = true;//  
         ShowText.Visible = true;//  
 
         //      
         if (name == "") {
           Response.Write("alert('        ')");
         }
 
         else{
 
             if (postfix == "jpg" || postfix == "gif" || postfix == "bmp" || postfix == "png")
             {
                 GetFiles.SaveAs(ipath);
                 ShowPic.ImageUrl = dpath;
                 ShowText.Text = "         :" + name + "
" + " :" + size + "KB" + "
" + " :" + type + "
" + " :" + ipath; } else { ShowPic.Visible = false;// GetFiles.SaveAs(fpath);// , upfile ShowText.Text = " :" + name + "
" + " :" + size + "KB" + "
" + " :" + type + "
" + " :" + fpath; }