/// <summary> /// xml反序列化 /// </summary> /// <param name="filePath"></param> /// <param name="type"></param> /// <returns></returns> public static object LoadRemoteXml(string host, string filePath, System.Type type) { HttpClient client = new HttpClient(); client.Url = host + "/" + filePath; client.Context.Cookies.Add(new Cookie("4", SecurityUtils.EncryptAES("1"), "/", ConfigUtil.GetConfig("domain"))); client.Context.Cookies.Add(new Cookie("0", SecurityUtils.EncryptAES("1"), "/", ConfigUtil.GetConfig("domain"))); client.Context.Cookies.Add(new Cookie("1", SecurityUtils.EncryptAES("1"), "/", ConfigUtil.GetConfig("domain"))); client.Context.Cookies.Add(new Cookie("2", SecurityUtils.EncryptAES("1"), "/", ConfigUtil.GetConfig("domain"))); client.Context.Cookies.Add(new Cookie("9", SecurityUtils.EncryptAES("1"), "/", ConfigUtil.GetConfig("domain"))); client.Context.Cookies.Add(new Cookie("10", SecurityUtils.EncryptAES("1"), "/", ConfigUtil.GetConfig("domain"))); try { using (Stream stream = client.GetStream()) { using (System.IO.StreamReader reader = new System.IO.StreamReader(stream, Encoding.UTF8)) { System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(type); try { object obj = xs.Deserialize(reader); reader.Close(); return(obj); } catch (Exception e) { reader.Close(); return(null); } } } } catch (Exception e) { return(null); } }
public void getpath() { xmlpath = DNTUtils.GetMapPath(ConfigUtil.GetConfig("ErrorLogPath") + "\\" + DateTime.Now.ToString("yyyyMMdd") + ".xml"); }