Barry
Fri Mar 14 08:27:15 CDT 2008
Here's a short and complete program that runs, but it doesn't show your
problem:
---8<---
using System;
using System.Net;
using System.IO;
namespace WebReq
{
class Program
{
static void Main(string[] args)
{
WebRequest req =
WebRequest.Create("
http://example.com/");
HttpWebResponse resp = (HttpWebResponse) req.GetResponse();
Console.WriteLine("Content-Lenght: {0}",resp.ContentLength);
Console.WriteLine("Content-Type: {0}", resp.ContentType);
byte[] buffer = new byte[10];
Stream stream = resp.GetResponseStream();
int bytesRead = stream.Read(buffer, 0, 10);
if (bytesRead>0)
{
Console.WriteLine("file is ok");
}
else
{
Console.WriteLine("bad file");
}
}
}
}
--->8---
I replaced the URL so that it would run. It would appear the problem is
in the URL. Can you find a different URL which reproduces the problem,
and show us it?
Achim Domma wrote:
> On 14 Mrz., 13:02, Jon Skeet [C# MVP] <sk...@pobox.com> wrote:
>
> > Could you post a short but complete program which demonstrates the
> > problem?
>
> I could not publish the original URL I'm downloading from, but here is
> my test code:
> The output is always the same, even for urls which can be downloaded
> via IE:
With the above program (not an mp3 download) I get:
Content-Lenght: 438
Content-Type: text/html; charset=UTF-8
file is ok
-- Barry
--
http://barrkel.blogspot.com/