Hi,
How can I read everything inside a Stream into a String or StringBuilder? O:-)
TIA 5 17089
Fernando,
If you know the encoding for the stream, just wrap the stream in a
StreamReader, and call the ReadToEnd. Be careful if you are reading from a
network stream, as this will cause it to hang if the stream is not
disconnected when done (as opposed to reading messages from the stream and
keeping it open).
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"Fernando Rodríguez" <fe************ *******@fernand o-rodriguez.com> wrote in
message news:re******** *************** *********@4ax.c om... Hi,
How can I read everything inside a Stream into a String or StringBuilder? O:-)
TIA
Does the Stream object represent just a character stream? In this case, you
can wrap it in a StreamReader and use its ReadToEnd method to read the whole
thing at once. This method returns a string.
"Fernando Rodríguez" <fe************ *******@fernand o-rodriguez.com> wrote in
message news:re******** *************** *********@4ax.c om... Hi,
How can I read everything inside a Stream into a String or StringBuilder?
O:-) TIA
On Mon, 18 Oct 2004 13:24:14 -0400, "Nicholas Paldino [.NET/C# MVP]"
<mv*@spam.guard .caspershouse.c om> wrote: Fernando,
If you know the encoding for the stream, just wrap the stream in a StreamReader , and call the ReadToEnd. Be careful if you are reading from a network stream, as this will cause it to hang if the stream is not disconnected when done (as opposed to reading messages from the stream and keeping it open).
Actually it's the return value of HttpWebResponse .GetResponseStr eam().
I'm afraid that what I need is a better understanding of Streams. Could you
point out some tutorial that cover streams and specifically network streams?
O:-)
TIA
On Mon, 18 Oct 2004 13:26:43 -0400, "Marina" <so*****@nospam .com> wrote: Does the Stream object represent just a character stream? In this case, you
It's an httpresponse for a web page, so yes, I guess it can only be text.
can wrap it in a StreamReader and use its ReadToEnd method to read the whole thing at once. This method returns a string.
OK :-)
Fernando,
You should be alright if you are using GetResponseStre am. It should
allow you to call ReadToEnd on the stream and get the result.
If you were using a NetworkStream though, it's different, as you can
send say, 32 over the wire (a space), but still have a connection, so the
stream is not complete yet. If you called ReadToEnd on that, then it would
wait for all of the bytes, and then for the stream to close, and therefore,
block.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"Fernando Rodríguez" <fe************ *******@fernand o-rodriguez.com> wrote in
message news:04******** *************** *********@4ax.c om... On Mon, 18 Oct 2004 13:24:14 -0400, "Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote:
Fernando,
If you know the encoding for the stream, just wrap the stream in a StreamReade r, and call the ReadToEnd. Be careful if you are reading from a network stream, as this will cause it to hang if the stream is not disconnecte d when done (as opposed to reading messages from the stream and keeping it open).
Actually it's the return value of HttpWebResponse .GetResponseStr eam().
I'm afraid that what I need is a better understanding of Streams. Could you point out some tutorial that cover streams and specifically network streams? O:-)
TIA This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Yechezkal Gutfreund |
last post by:
I have been using the following code (successfully) to read Xml formated
text packets from a TCP stream. The output from the server stream consists
of a sequence of well formed Xml documents written to the output stream.
We are willing to pay $ to any expert (e.g. MVP) consultant who has to time
to help us track down this problem.
(we...
|
by: Yogi_Bear_79 |
last post by:
pardon my ignorance as I am a self-taught hobbyist programmer.
I am curious after reading up on SharpZipLib. Can I embed a zipped txt file
in my program? Then either read from within the zip file or unzip and read
it? I currently have an embedded text file that contains a list that is
read into an array. I'm always looking to save...
|
by: Just D. |
last post by:
All!
How should we read any file from some URL? I found in MSDN the method
URLDownloadToFile function, but it's for C#. There is another example to
read but it doesn't work if the page is more complicated and includes not
only HTML code but JAVA scripts, etc. Strange, but it doesn't work for me.
// Creates an HttpWebRequest with the...
|
by: eiji |
last post by:
Hi folks,
I'm new to binary-file handling and try to work/learn playing around
with MD5.
Now everything works fine with small files, but when files get
bigger(e.g. 28MB) this loop stops in the second read()! I don't know
why!
typedef basic_ifstream<unsigned char> ifstream_uc;
void MD5::update (unsinged char *input, unsinged int...
|
by: computerwolf8 |
last post by:
I have a file where I know the lines go as follows:
string
long
string
int
int
string
double
| |
by: WStoreyII |
last post by:
the following code is supposed to read a whole line upto a new line
char from a file. however it does not work. it is producing weird
results. please help. I had error checking in there for mallocs and
ect, but i removed them to help me debug. thanks.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void freadl ( FILE...
|
by: Jack |
last post by:
Hi,
I want to read a string a chars from a stream, and put it into a
string.
At the moment, I'm creating a buffer of a fixed size, and reading the
stream of text into it. It works, but I have to create a buffer of a
pre-defined length: (ConstBufferByteSize=10000000). How can I read a
stream into a buffer or string without knowing the...
|
by: vishnu |
last post by:
Hi,
Am trying to post the data over https and am getting error in
httpwebresponse.getResponseStream.Please help me to get rid of this
issue.
Here is the message from immediate window
?myResp.GetResponseStream()
{System.Net.ConnectStream}
|
by: dm3281 |
last post by:
Hello, I have a text report from a mainframe that I need to parse.
The report has about a 2580 byte header that contains binary information
(garbage for the most part); although there are a couple areas that have
ASCII text that I need to extract. At the end of the 2580 bytes, I can read
the report like a standard text file. It should have...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |