我需要一些方法来检查下载文件的大小,而无需下载整个文件。我使用C#和System.Net.WebClient做检查需要在一个asp.net web服务运行downloads.The。
I need some way to check the size of a download without having to download the entire file. I am using C# and the System.Net.WebClient to do the downloads.The check needs to run in a asp.net webservice.
感谢
使用HTTP方法 HEAD ,以获取的Content-Length:头
Use HTTP method HEAD to retrieve Content-Length: header.
HEAD / HTTP/1.1
Host: www.example.com
HTTP/1.1 200 OK
Date: Wed, 18 Mar 2009 11:21:51 GMT
Server: Apache/2.2.3 (CentOS)
Last-Modified: Tue, 15 Nov 2005 13:24:10 GMT
ETag: "b80f4-1b6-80bfd280"
Accept-Ranges: bytes
Content-Length: 438
Connection: close
Content-Type: text/html; charset=UTF-8
上一篇:列表,IList的和IEnumerable的比较列表、IList、IEnumerable
下一篇:Thread.VolatileRead()与Volatile.Read()VolatileRead、Thread、Read、Volatile