/// <summary>
        
/// 遍历CookieContainer
        
/// </summary>
        
/// <param name="cc"></param>
        
/// <returns></returns>
        public static List<Cookie> GetAllCookies(CookieContainer cc)
        {
            List<Cookie> lstCookies = new List<Cookie>();

            Hashtable table = (Hashtable)cc.GetType().InvokeMember("m_domainTable",
                System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.GetField |
                System.Reflection.BindingFlags.Instance, null, cc, new object[] { });

            foreach (object pathList in table.Values)
            {
                SortedList lstCookieCol = (SortedList)pathList.GetType().InvokeMember("m_list",
                    System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.GetField
                    | System.Reflection.BindingFlags.Instance, null, pathList, new object[] { });
                foreach (CookieCollection colCookies in lstCookieCol.Values)
                    foreach (Cookie c in colCookies) lstCookies.Add(c);
            }
            return lstCookies;
        }

相关文章:

  • 2021-07-28
  • 2021-09-16
  • 2021-08-15
  • 2021-11-16
  • 2022-02-10
  • 2022-01-20
  • 2022-12-23
  • 2021-11-14
猜你喜欢
  • 2021-09-15
  • 2022-12-23
  • 2021-06-19
  • 2022-12-23
  • 2021-06-14
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案