zoukankan      html  css  js  c++  java
  • 物理删除文件 业务层

     public void Delete(string projectID, string strItemID, string strType)
           {
               string AppPath = "";
               HttpContext HttpCurrent = HttpContext.Current;

               if (HttpCurrent != null)
               {
                   AppPath = HttpCurrent.Server.MapPath("~");
               }
               else
               {
                   AppPath = AppDomain.CurrentDomain.BaseDirectory;
                   if (Regex.Match(AppPath, @"\\$", RegexOptions.Compiled).Success)
                       AppPath = AppPath.Substring(0, AppPath.Length - 1);
               }

               //AppPath = AppPath + "\\ResourceFiles\\";

               string strPath = "";
            
              
              DataSet ds=new DataSet();
              ds=GetDataByItemID(projectID,strItemID,strType);
              if(ds!=null&&ds.Tables.Count>0 && ds.Tables[0].Rows.Count>0)
              {
                  for(int i=0;i<ds.Tables[0].Rows.Count;i++)
                  {
                      strPath = ds.Tables[0].Rows[i]["Path"].ToString();
                      strPath = strPath.Substring(2,strPath.Length-2);
                      strPath = AppPath + strPath;
                      File.Delete(strPath);

                  }
              }
              

             
               string strSQL;
               strSQL = "delete from Resource where ProjectInfoID=" + projectID + " and comment='" + strType + "' and  ProcessSetID ='" + strItemID + "' ";
               sa.ExecuteSQL(strSQL);


           }

  • 相关阅读:
    .NET中常用获取程序根目录的方法
    多态的实现
    9个优秀网上免费标签云生成工具
    Asp.Net自定义错误页心得介绍
    C# string.Format 格式化使用说明
    接口编程,反射创建对象
    DllImport使用的一点整理
    System.Data.ConstraintException: 未能启用约束。一行或多行中包含违反非空、唯一或外键约束的值。
    C# OleDb读取Excel文件 避免出现 科学计数法 的列
    C++翻译C#
  • 原文地址:https://www.cnblogs.com/lgzh3/p/1333643.html
Copyright © 2011-2022 走看看