典型的邏輯錯誤!

來源:互聯網
上載者:User

    string tableNameStr=Request.Params["delTbName"]==null?"":Request.Params["delTbName"]; 
     string id=Request.Params["id"]==null?"":Request.Params["id"];
     string IsRecord=Request.Params["RecGuid"]==null?"":Request.Params["RecGuid"];
     string sqlDel="";

     string[] recGuidAry = getSubRecStr( tableNameStr,IsRecord).Split(',');

     if( id!="")
      sqlDel="delete from  "+tableNameStr+"  where id='"+id+"'" ;

     string sqlDelSub="";
     if( IsRecord !="" )
      sqlDelSub ="delete from  "+tableNameStr+"  where ParentRecGuid ='"+ IsRecord +"'" ;

     if(  dbP.runSqlCmdText(sqlDelSub)[1] != null )
     {
      showAlertPageEdit("刪除子記錄失敗。",true,true);
      Response.End();
     }

     if(  dbP.runSqlCmdText(sqlDel)[1] != null )
     {
      showAlertPageEdit("刪除記錄失敗。",true,true);
      Response.End();
     }

     string s=System.Configuration.ConfigurationSettings.AppSettings.Get("attachment");
     try
     {
      if( recGuidAry.Length >1 )
      {
       for(int i=0;i<recGuidAry.Length;i++ )
       {
        if( Directory.Exists( Path.Combine(s,"attachment//"+ReGuidStr+"//"+recGuidAry[i]) )  &&  recGuidAry[i]!="" )
        {
         Directory.Delete( Path.Combine(s,"attachment//"+ReGuidStr+"//"+recGuidAry[i]),true);
        }
       }
      }
     }
     catch
     {
      //showAlertPageEdit("附件刪除失敗。",true,true);
      //Response.End();
     }

     try
     {
      if( Directory.Exists( Path.Combine(s,"attachment//"+ReGuidStr+"//"+IsRecord) ) && IsRecord != ""   )
      {
       Directory.Delete( Path.Combine(s,"attachment//"+ReGuidStr+"//"+IsRecord),true);
      }
     }
     catch
     {
      showAlertPageEdit("附件刪除失敗。",true,true);
      Response.End();
     }
     showAlertPageEdit("刪除成功。",true,true);

 

 

上面是我的一個函數中的代碼,因為沒有加紅色的代碼,而導致在我的 recGuidAry[i]   and   IsRecord 的時候我的整個檔案夾都被刪除了!

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.