System.Net.WebClient webClient=new System.Net.WebClient();
Stream stream = webClient.OpenRead(SourceURL);
byte[] arrByte = new byte[1024];
long completedByteCount = 0;
if (File.Exists(DestPath))
{
File.Delete(DestPath);
}
FileStream fStream = new FileStream(DestPath,FileMode.CreateNew,FileAccess.Write);
while(true)
{
int readCnt = stream.Read(arrByte,0,1024);
if(readCnt==0) break;      
fStream.Write(arrByte,0,readCnt);
completedByteCount += readCnt;
double percent=(int)((float)completedByteCount / FileLength*100) ;
CompletedProseccEventArgs e=new CompletedProseccEventArgs(percent,completedByteCount);
OnCompletedProsecc(e);
}              
stream.Close();
fStream.Close();
以上的代码可以实现下载,可是我却不知道如何在下载前获得服务器上文件的大小。也就是代码中的FileLength!!!请大家帮忙。。谢谢,盼复。。急。。