 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
dzeidzei Guest
|
Posted: Tue Nov 15, 2005 5:36 am Post subject: How to read TMemoryStream contents to AnsiString? |
|
|
Hi,
I have a TMemoryStream containing string(s), (response from IdHTTP->Post), and I'd like to put that response to AnsiString.
And don't know how to do that. Could someone help?
- dzeidzei
|
|
| Back to top |
|
 |
JD Guest
|
Posted: Tue Nov 15, 2005 6:30 am Post subject: Re: How to read TMemoryStream contents to AnsiString? |
|
|
"dzeidzei" <dzeidzei (AT) suolakaivos (DOT) com> wrote:
| Quote: |
I have a TMemoryStream containing string(s), [...] I'd like
to put that response to AnsiString.
|
Use a TStringList and it's LoadFromStream method.
~ JD
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Tue Nov 15, 2005 7:19 am Post subject: Re: How to read TMemoryStream contents to AnsiString? |
|
|
"dzeidzei" <dzeidzei (AT) suolakaivos (DOT) com> wrote
| Quote: | I have a TMemoryStream containing string(s), (response
from IdHTTP->Post), and I'd like to put that response to
AnsiString.
|
Why not just use the overloaded version of Post() that returns an AnsiString
instead of filling a TStream? You do know that TIdHTTP has several
overloaded methods, right?
If you must continue using a TMemoryStream, then cast the TMemoryStream's
Memory property to char*, ie:
AnsiString str( (char*) stream->Memory, stream->Size );
Alternatively:
AnsiString str;
str.SetLength(stream->Size);
stream->Position = 0;
stream->Read(str.c_str(), stream->Size);
Or, use a TStringStream instead of a TMemoryStream. TStringStream has a
DataString property that already contains the stream content as an
AnsiString.
Gambit
|
|
| Back to top |
|
 |
dzeidzei Guest
|
Posted: Tue Nov 15, 2005 12:40 pm Post subject: Re: How to read TMemoryStream contents to AnsiString? |
|
|
"Remy Lebeau (TeamB)" <no.spam (AT) no (DOT) spam.com> wrote:
| Quote: |
Why not just use the overloaded version of Post() that returns an AnsiString
instead of filling a TStream? You do know that TIdHTTP has several
overloaded methods, right?
|
Unfortunately, my Indy lib is so old that it only supports TMemoryStream :-(
But I got it done with TStringStream, as You arvised.
Thanks!
- dzeidzei
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Wed Nov 16, 2005 10:02 pm Post subject: Re: How to read TMemoryStream contents to AnsiString? |
|
|
"dzeidzei" <dzeidzei (AT) suolakaivos (DOT) com> wrote
| Quote: | Unfortunately, my Indy lib is so old that it only supports TMemoryStream
 |
Then you should serously consider upgrading to a newer version.
Gambit
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|