public DataTable GetDataFromHTML(string strHTML, string strID, DataTable dt) { string strTemp = ""; DataRow dr = dt.NewRow(); dr["ÐòºÅ"] = strID; StringBuilder sb = new StringBuilder(); do { strTemp = Regex.Match(strHTML, @"<TEXTAREA[\s\S]*?</TEXTAREA>", RegexOptions.IgnoreCase).Value; strHTML = Regex.Replace(strHTML, strTemp, "", RegexOptions.IgnoreCase | RegexOptions.Singleline); if (strHTML == "" || strTemp == "") { break; } strHTML = strHTML.Replace(strTemp, ""); string strId = Regex.Match(strTemp, @"name=[\s\S]*?( |>)", RegexOptions.IgnoreCase).Value; if (strId.IndexOf('=') > 0) { strId = strId.Substring(8, strId.Length - 8 - 1); } string strValue = Regex.Match(strTemp, @">[\s\S]*?</TEXTAREA>", RegexOptions.IgnoreCase).Value; strValue = strValue.Replace("</TEXTAREA>", ""); int j = strValue.LastIndexOf('>'); if (j >= 0) { strValue = CFun.Right(strValue, strValue.Length - j - 1); //strValue = strValue.Substring(j+1, strValue.Length-j); } else { strValue = ""; } //if (strValue.IndexOf('/') > 0) //{ // strValue = strValue.Substring(1, strValue.Length - 11 - 1); //} //else //{ // strValue = ""; //} if (strId != "") { dr[strId] = strValue; } }while (strTemp != ""); dt.Rows.Add(dr); return(dt); }
/// <summary> /// 文件下载(文件推送型) /// </summary> /// <param name="filename">文件名含相对路径</param> /// <param name="isFullPath">是否物理地址1是 0 不是</param> public static void FileDown(string filename, string isFullPath) { if (filename != "") { if (isFullPath == "0") { if (CFun.Left(filename, 1) == "/") { filename = filename.Replace("/", "\\"); } if (CFun.Left(filename, 1) == @"\") { filename = System.Web.HttpContext.Current.Request.PhysicalApplicationPath + CFun.Right(filename, filename.Length - 1); } else { filename = System.Web.HttpContext.Current.Request.PhysicalApplicationPath + filename; } } System.IO.FileInfo file = new System.IO.FileInfo(filename); if (file.Exists) { System.Web.HttpContext.Current.Response.Clear(); System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(file.Name, System.Text.Encoding.UTF8)); System.Web.HttpContext.Current.Response.AddHeader("Content-Length", file.Length.ToString()); System.Web.HttpContext.Current.Response.ContentType = "application/octet-stream"; System.Web.HttpContext.Current.Response.Filter.Close(); System.Web.HttpContext.Current.Response.WriteFile(file.FullName); System.Web.HttpContext.Current.Response.End(); } else { CFun.JsAlerT("文件不存在!"); //System.Web.HttpContext.Current.Response.Redirect("/error.aspx?msg=文件不存在!"); } } }