Re: Strange problem with streamwriter & webrequest
From: Jon Skeet [C# MVP] (skeet_at_pobox.com)
Date: 07/27/04
- Next message: Jon Skeet [C# MVP]: "Re: Basic File I/O in C#"
- Previous message: Mike Kitchen: "Re: PlaySound question"
- In reply to: the friendly display name: "Strange problem with streamwriter & webrequest"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 27 Jul 2004 08:08:53 +0100
<"=?Utf-8?B?dGhlIGZyaWVuZGx5IGRpc3BsYXkgbmFtZQ==?=" <the friendly
display name@discussions.microsoft.com>> wrote:
<snip>
> The file i try to download is a ascii text file, and the only reason
> i have chosen it, was, because google has shown it as one of the
> first, for my search for text files.
>
> The code is really simple, the problem is:
>
> It hangs. Try to compile this, the first bytes are shown in the
> console, and are written into the log2.txt file, but, then.. it does
> nothing, til the thread sleep is over.
It doesn't hang, actually. It throws an exception in the worker thread,
which isn't seen. The problem is that you're closing the StreamWriter
and then trying to write to it again.
> If i remove
>
> sw.Write(s) and sw.Close from the whencomplete callback, the whole
> ascii file is going to be displayed in the console. (unlike before,
> only few bytes of it are shown, then, it hangs)
>
> And now the interesting part:
>
> if i copy the text file to my local computer, into the
> inetpub\wwwroot folder (i have iis 5 installed, the OS is windows
> 2000 professional), activate the iis, and change the path in the
> maker function for the textfile to http://localhost/battery.txt , the
> application works fine. It displays all the contents of the text
> file, while copying to the log2.txt without any problems.
That sounds very odd - are you sure you hadn't made any other changes
to the code, such as raising the buffer size or removing the call to
sw.Close()?
-- Jon Skeet - <skeet@pobox.com> http://www.pobox.com/~skeet If replying to the group, please do not mail me too
- Next message: Jon Skeet [C# MVP]: "Re: Basic File I/O in C#"
- Previous message: Mike Kitchen: "Re: PlaySound question"
- In reply to: the friendly display name: "Strange problem with streamwriter & webrequest"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|