问题描述
我在 URI 中有一个 10 mb 的文件我用以下代码下载.
I have a 10 mb file at an URII download it with the following codes.
WebClient wc = new WebClient();string file = wc.DownloadString(http://www......com);
WebClient wc = new WebClient();string file = wc.DownloadString(http://www......com);
我可以下载特定大小的文件吗,例如 1 mb、5 mb.不是整个 10 mb.?然后停止下载?
Can I download certain sizes of this file, such as 1 mb, 5 mb. not whole 10 mb. ?Then stop downloading?
谢谢.
推荐答案
您可以使用 httpwebrequest 来获取响应.加载任何你想要的行.查看:http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.getresponse%28v=vs.71%29.aspx
you can use httpwebrequest to getresponse. load whatever lines you want. check:http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.getresponse%28v=vs.71%29.aspx
示例使用 ReadToEnd.您可以使用其他方法读取其中的一部分.
the example use ReadToEnd. you can use other methods to read just part of it.
这篇关于webclient 下载字符串(URI),URI 有 10 mb 文件.我可以下载一定大小的这个文件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!