通过DataTable(dt)、指定字段名(strName)和网站属性(hc),删除-/打头的上传文件 - DeleteUploadFile8DataTable

2017-03-05 09:48:45  访问(2058) 赞(0) 踩(0)


        /// <summary>
        /// 通过DataTable(dt)、指定字段名(strName)和网站属性(hc),删除-/打头的上传文件 - DeleteUploadFile8DataTable +
        /// </summary>
        /// <param name="hc"></param>
        /// <param name="dt"></param>
        /// <param name="strName"></param>
        public void DeleteUploadFile8DataTable
            (
                HttpContext hc,
                DataTable dt,
                string strName
            )
        {
            if (hc == null)
                return;

            if (dt == null)
                return;

            if (strName == null || strName.Length == 0)
                return;

            string phyPath = hc.Request.PhysicalApplicationPath;

            string str = null;
            string fullName = null;

            foreach (DataRow dr in dt.Rows)
            {
                str = dr[strName].ToString();

                if (str == null || str.Length == 0)
                    continue;

                if (!str.StartsWith("-/"))
                    continue;


                fullName = phyPath + str.Substring(2);

                if (!File.Exists(fullName))
                    continue;

                File.Delete(fullName);
            }
        }


标签:通过DataTable(dt)、指定字段名(strName)和网站属性(hc),删除-/打头的上传文件 - DeleteUploadFile8DataTable 

上一条:

下一条:


 

相关评论

评论加载中……
 

发表评论

类型:
内容:
  (Alt+Enter)