下载前检查下载大小 [英] Checking Download size before download

查看:131
本文介绍了下载前检查下载大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一些方法来检查下载文件的大小,而无需下载整个文件。我使用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

这篇关于下载前检查下载大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆