|
可以正常下载文件,文件内容也正常,但是 获取Header里面的
attachment; filename=ÎåÄ꼶ÓïÎÄϲáµÚ¶þ×é5¡¶¹ÅÊ«´ÊÈýÊס·´Ê¾ä½âÎöÐÂÈ˽̰æ.doc
出现上面的乱码,我想获取正确的filename,不知道该怎么设置
HttpItem item = new HttpItem()
{
URL = "http://club.dearedu.com/plus/download_iweike_test.php?open=2&id=5695312&uhash=c0720d33bfaca04bca1ec6b8",//URL 必需项
//Encoding = System.Text.Encoding.GetEncoding("UTF-8"),//URL 可选项 默认为Get
Method = "get",//URL 可选项 默认为Get
IsToLower = false,//得到的HTML代码是否转成小写 可选项默认转小写
Cookie = "",//字符串Cookie 可选项
Postdata = "",//Post数据 可选项GET时不需要写
Timeout = 100000,//连接超时时间 可选项默认为100000
ReadWriteTimeout = 30000,//写入Post数据超时时间 可选项默认为30000
Allowautoredirect = true,//是否根据301跳转 可选项
UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",////用户的浏览器类型,版本,操作系统 可选项有默认值
ContentType = "application/octet-stream",
ResultType = ResultType.Byte,
Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,;q=0.8"
};
Random Random1 = new Random();
HttpResult result = http.GetHtml(item);
byte[] data = result.ResultByte;
string filename = result.Header["Content-Disposition"].ToString();
FileStream fs = new FileStream(AppDomain.CurrentDomain.BaseDirectory + "1.doc", FileMode.Create);
fs.Write(data, 0, data.Length);
fs.Flush();
fs.Close();
|
|