- 1、本文档共4页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
winform通过HttpWebRequest(post方式)上传文件和传递参数
winform 通过HttpWebRequest (post 方式)上传文件和传递参数
1 private void button1_Click(object sender, EventArgs e)
2 {
3 UploadFileHttpRequest(AppDomain.CurrentDomain.BaseDirectory.
Trim() + bb.txt);
4 }
5 private string UploadFileHttpRequest(string fileName)
6 {
7 string output = string.Empty;
8 MemoryStream postStream = null;
9 BinaryWriter postWriter = null;
10 HttpWebResponse response = null;
11 StreamReader responseStream = null;
12
13 const string CONTENT_BOUNDARY =
ae0cH2cH2GI3Ef1KM7GI3Ij5cH2gL6;
14 const string CONTENT_BOUNDARY_PREFIX = --;
15
16 try
17 {
18 UriBuilder uriBuilder = new UriBuilder(http://localhost:7408/
WebT/t.aspx);
19 HttpWebRequest request = (HttpWebRequest)WebRequest.Cre
ate(uriBuilder.Uri);
20 request.UserAgent = Mozilla/4.0 (compatible; MSIE 6.0; Wind
ows NT 5.2; SV1; Maxthon; .NET CLR 1.1.4322; .NET CLR 2.0.50727);
21 request.Timeout = 300000;
22 request.ContentType = multipart/form-
data; boundary= + CONTENT_BOUNDARY;
23 postStream = new MemoryStream();
24 postWriter = new BinaryWriter(postStream);
25 //-- 参数
26 //param[setType]
27 postWriter.Write(Encoding.GetEncoding(gb2312).GetBytes(C
ONTENT_BOUNDARY_PREFIX + CONTENT_BOUNDARY + \r\n +
28 Content-Disposition: form-
data; name=\param[setType]\ \r\n\r\n));
29 postWriter.Write(Encoding.GetEncoding(gb2312).GetBytes(
2));
30 postWriter.Write(Encoding.GetEncoding(gb2312).GetBytes(\
r\n));
31 //param[startTime]
32 postWriter.Write(Encoding.GetEncoding(gb2312).Get
您可能关注的文档
- Analysis of the Chinese central sentence of the learners - construct double into a prime(分析中国学习者的中心句子构造双').doc
- Analysis of the Chinese Communist Party leaders insist on the objective necessity(分析中国共产党领导人坚持客观必然性).doc
- Analysis of the Chinese consumer confidence index(分析中国消费者信心指数).doc
- Analysis of the Chinese dairy industry Empirical Analysis of the combined effect of(分析中国乳制品行业的综合效应的实证分析).doc
- Analysis of the Chinese elements in the modern packaging design of the network using(分析中国元素在现代包装设计的网络使用).doc
- Analysis of the Chinese Language and Literature (senior secretary) undergraduate thesis paper writing(分析汉语言文学(高级秘书)本科生论文写作).doc
- Analysis of the Chinese Language and Literature Analysis of the status of teaching(分析汉语言文学教学的现状分析).doc
- Analysis of the Chinese Language and Literature Teaching(分析语文教学).doc
- Analysis of the Chinese language and literature to explore the application of the modified network(汉语言文学的分析探索修改网络的应用).doc
- Analysis of the Chinese medicine treatment of primary dysmenorrhea(分析原发性痛经的中药治疗).doc
最近下载
- DL∕T 5168-2023表A.5 分部工程质量控制资料核查记录.pdf VIP
- 大班数学活动《8的分解组成》PPT课件.ppt
- 【一模】2025年广东省2025届高三高考模拟测试 (一) 数学试卷(含官方答案及解析 ).docx
- 13S201 室外消火栓及消防水鹤安装.docx VIP
- 主题班会课件-师恩难忘-学子感恩-致敬恩师主题班会.ppt
- GB50327-2001住宅装饰装修工程施工规范.docx
- World怎么在参考文献后面添加CrossRef.pdf VIP
- 江苏省房屋建筑和市政基础设施工程标准施工招标文件(适用于资格后审).doc VIP
- 八下英语U3词性变化.docx
- 《机械原理》期末考试试题及答案.docx
文档评论(0)