Hi,
I do a webrequest and it returns some text data in a stream. I want to
put this text data into a string. I've got it working just fine, but I
have to
put the text data into into a fixed-size buffer BEFORE I put it into a
string (ConstBufferByt eSize=1000000). This fixed size buffer wastes
space. Is
it possible to somehow assign it straight to a string, or somehow do
this 'dynamically' ?
'' Put the XML response into a string to display
Dim tempBuffer(Cons tBufferByteSize ) As Byte
Dim enc As New System.Text.ASC IIEncoding
' responseStream. Length.ToString () ' <- Can't seem to get
the length to signify the buffer size here ???
responseStream. Read(tempBuffer , 0,
ConstBufferByte Size) ' Read from the stream x bytes and put into a
temporary buffer
responseStream. Close() ' Close
the request stream to free up resources
strResponse =
enc.GetString(t empBuffer) ' Put the response into
a string (finally!)
Any kind of help will do,
thankyou
Jack. 4 1856
Jack <br*********@ho tmail.comwrote in news:1185337001 .737276.37620
@m37g2000prh.go oglegroups.com:
put the text data into into a fixed-size buffer BEFORE I put it into a
string (ConstBufferByt eSize=1000000). This fixed size buffer wastes
space. Is
it possible to somehow assign it straight to a string, or somehow do
this 'dynamically' ?
The buffer is used by the web request to buffer the incoming request.
Strings are immutable, so a new copy of the string is created each time it
is changed. Thus .NET probably buffers to memory first, then builds a
string afterwards for efficiency sake.
On Jul 25, 2:32 pm, Spam Catcher <spamhoney...@r ogers.comwrote:
Jack <bradnerd...@ho tmail.comwrote in news:1185337001 .737276.37620
@m37g2000prh.go oglegroups.com:
put the text data into into a fixed-size buffer BEFORE I put it into a
string (ConstBufferByt eSize=1000000). This fixed size buffer wastes
space. Is
it possible to somehow assign it straight to a string, or somehow do
this 'dynamically' ?
The buffer is used by the web request to buffer the incoming request.
Strings are immutable, so a new copy of the string is created each time it
is changed. Thus .NET probably buffers to memory first, then builds a
string afterwards for efficiency sake.
OK. So I need to put the stream into a fixed sized buffer first? Isn't
there another way?
On Jul 24, 11:16 pm, Jack <bradnerd...@ho tmail.comwrote:
Hi,
I do a webrequest and it returns some text data in a stream. I want to
put this text data into a string. I've got it working just fine, but I
have to
put the text data into into a fixed-size buffer BEFORE I put it into a
string (ConstBufferByt eSize=1000000). This fixed size buffer wastes
space. Is
it possible to somehow assign it straight to a string, or somehow do
this 'dynamically' ?
'' Put the XML response into a string to display
Dim tempBuffer(Cons tBufferByteSize ) As Byte
Dim enc As New System.Text.ASC IIEncoding
' responseStream. Length.ToString () ' <- Can't seem to get
the length to signify the buffer size here ???
responseStream. Read(tempBuffer , 0,
ConstBufferByte Size) ' Read from the stream x bytes and put into a
temporary buffer
responseStream. Close() ' Close
the request stream to free up resources
strResponse =
enc.GetString(t empBuffer) ' Put the response into
a string (finally!)
Any kind of help will do,
thankyou
Jack.
Just set your buffer size to something smaller, like 8K. The Read
method should return how many bytes were actually read. You would
have to read in a loop until Read returns 0 indicating the end of the
stream.
Chris
On Tue, 24 Jul 2007 21:16:41 -0700, Jack <br*********@ho tmail.com>
wrote:
>Hi,
I do a webrequest and it returns some text data in a stream. I want to put this text data into a string. I've got it working just fine, but I have to
put the text data into into a fixed-size buffer BEFORE I put it into a string (ConstBufferByt eSize=1000000). This fixed size buffer wastes space. Is
it possible to somehow assign it straight to a string, or somehow do this 'dynamically' ?
'' Put the XML response into a string to display
Dim tempBuffer(Cons tBufferByteSize ) As Byte
Dim enc As New System.Text.ASC IIEncoding
' responseStream. Length.ToString () ' <- Can't seem to get the length to signify the buffer size here ???
responseStream. Read(tempBuffer , 0, ConstBufferByt eSize) ' Read from the stream x bytes and put into a temporary buffer
responseStream .Close() ' Close the request stream to free up resources
strResponse = enc.GetString( tempBuffer) ' Put the response into a string (finally!) Any kind of help will do,
thankyou
Jack.
I haven't tried this, but what about :
' Define ConstBufferByte Size to somthing like 1024
Dim tempBuffer(Cons tBufferByteSize ) as Byte
Dim str As StringBuilder = New StringBuilder
Do While True
Dim len As Integer
len = responseStream. Read(tempBuffer , 0, ConstBufferByte Size)
If len = 0
Exit Do
End If
str.Append(enc. GetString(tempB uffer, 0, len))
End Do
strResponse = str.ToString() This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: John Smith |
last post by:
Here is my HTML table formatting code.
<table border="1" width="100%">
<tr width = "100%">
<td
width="33%">11asdhagdshaskgashjgahjgadhjgdjshdgasjdgajdgadjhgdgahjdgadhjsgad
|
by: Terry Olsen |
last post by:
Is there a good way to find a pattern of bytes/chars in a stream? I've got
a serial port connected to a tcp port. I need to be able to catch a unique
character string in the stream so that I can perform certain functions. For
example, I have a telnet client connected to an Apple II through the serial
port. The user at the telnet terminal is using the BBS running on the Apple
II just like the good ole days of dialup BBS's. I need to be...
|
by: Daniel |
last post by:
Hi,
Does anyone know if it is possible to put an aspx page inside of another? OR
run an aspx page and capture the output as a string and then write this out
to a page....
So for example say you have a page that takes an id number as a query string
and displays different things based on that id number.
If you were able to loop through running the aspx pages with id=100, id=200,
|
by: sherifffruitfly |
last post by:
Hi,
I've a got a little (exercise) program that reads data from a file and
puts it into struct members. I run into trouble when one of the data
pieces is comprised of several words (eg "john doe", with a space in
it).
For console input, cin.getline(var, howMuchIWant) or cin.get() has done
the trick for me in the past. It doesn't seem to work for me nearly so
well with a file stream. I wouldn't have thought cpp regarded
|
by: fakeprogress |
last post by:
For a homework assignment in my Data Structures/C++ class, I have to
create the interface and implementation for a class called Book, create
objects within the class, and process transactions that manipulate (and
report on) members of the class.
Interface consists of:
- 5 private variables
char author;
char title;
char code;
| |
by: sven.suursoho |
last post by:
Hello,
In main(), the first output API is what I try to achieve. Unfortunately
it fails, printing first string as pointer instead of human readable
message. Tried to initialize str(""), set new buffer etc, but nothing
worked.
Ideas? Also might use another internal construct, only API is needed
and requirement to reuse existing std::ostream inserters.
|
by: Miro |
last post by:
VB 2003
at the end of the code, this works great.
bytCommand = Encoding.ASCII.GetBytes("testing hello send text")
udpClient.Send(bytCommand, bytCommand.Length)
and this recieves it
Dim strReturnData As String = _
System.Text.Encoding.ASCII.GetString(receiveBytes)
|
by: anachronic_individual |
last post by:
Hi all,
Is there a standard library function to insert an array of characters
at a particular point in a text stream without overwriting the existing
content, such that the following data in appropriately moved further
down? From a cursory search of the libc documentation I can't find such
a function. Will I have to write it myself?
Thanks.
|
by: Timofmars |
last post by:
I'm try to Unload DB2 data from a table into a record sequential file
on NT. I can an unload on Mainframe, but it doesn't seem to be an
option in NT.
In NT, all I can do is export/import. I can do a Load too, but not an
Unload. I just want the only the data from the table in a record
sequential file. Export seems only to give options to have a delimited
line sequential file or a record sequential file where the data is
preceeded by...
|
by: markclinn |
last post by:
I have a device in the field that I access by the stream method.
I open the Stream and do the following:
1. stream.write a character to the device.
2. stream.read the information from the device.
The problem is that when I am debugging and step through the code there is a long enough pause that I recieve the entire string. If I just run it, I only get the 1st character. I have attached the code below.
Public Class Form1
...
|
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |