社区
C#
帖子详情
WebClient.DownloadFile下载文件,URL包含中文的问题
leavesosoon
2017-03-21 05:11:47
System.Net.WebClient webClient = new System.Net.WebClient();
webClient.DownloadFile("http://localhost:8080/downloadfile/中文测试.txt", "D\中文测试.txt");
我用这种方式进行下载文件,但是URL包含中文,解析不到地址,导致报错404.应该怎么搞?
...全文
382
3
打赏
收藏
WebClient.DownloadFile下载文件,URL包含中文的问题
System.Net.WebClient webClient = new System.Net.WebClient(); webClient.DownloadFile("http://localhost:8080/downloadfile/中文测试.txt", "D\中文测试.txt"); 我用这种方式进行下载文件,但是URL包含中文,解析不到地址,导致报错404.应该怎么搞?
复制链接
扫一扫
分享
转发到动态
举报
AI
作业
写回复
配置赞助广告
用AI写文章
3 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
wuxiaol2
2017-10-20
打赏
举报
回复
System.Net.WebClient webClient = new System.Net.WebClient(); 这样 webClient.DownloadFile(Server.HtmlEncode("http://localhost:8080/downloadfile/中文测试.txt"), "D\中文测试.txt"); 或这样 webClient.DownloadFile(HttpUtility.HtmlEncode("http://localhost:8080/downloadfile/中文测试.txt"), "D\中文测试.txt");
Hvai
2017-10-20
打赏
举报
回复
我也遇到这问题,有搞定吗?
SoulRed
2017-03-21
打赏
举报
回复
encoder 一下。转码。
C#中
WebClient
实现
文件
下载
你可以通过调用其`
Download
File
`方法来
下载
一个
文件
,该方法接受一个
URL
和本地
文件
路径作为参数。例如: ```csharp using (
WebClient
wc = new
WebClient
()) { wc.
Download
File
("http://example.com/
file
", ...
C#
webClient
.
Download
File
Async异步源码
本教程将详细解释`
WebClient
.
Download
File
Async`方法,这是一个异步
下载
文件
的功能,适用于C#开发者,特别是初学者。我们将探讨异步编程的基本概念,`
Download
File
Async`的工作原理,以及如何在实际项目中应用。 1....
使用
WebClient
实现
文件
下载
`
WebClient
`类提供了`
Download
File
`方法,可以直接将网络上的
文件
下载
到本地。例如,我们可以这样
下载
一个
文件
: ```csharp using (var client = new
WebClient
()) { client.
Download
File
(...
用
WebClient
.UploadData方法上载
文件
数据的方法
### 使用
WebClient
.UploadData方法上传
文件
数据详解 #### 一、引言 在现代Web开发中,客户端与服务器之间的交互非常频繁,其中一种常见的需求就是从客户端向服务器上传
文件
。在.NET Framework中,`
WebClient
` 类...
WebClient
上传
下载
文件
与上传类似,`
WebClient
`也提供了`
Download
File
`和`
Download
File
Async`方法来
下载
文件
。同样,异步版本`
Download
File
Async`更适合于需要响应速度和用户体验的应用。`
Download
File
Async`接收两个参数:一个是服务器上...
C#
111,096
社区成员
642,554
社区内容
发帖
与我相关
我的任务
C#
.NET技术 C#
复制链接
扫一扫
分享
社区描述
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧
+ 用AI写文章