Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 338
  • Last Modified:

STream Reader and buffer

In my code below, is there a way I can set the readBuff dynamically?

While streamResponse.CanRead
    Dim streamRead As New StreamReader(streamResponse)
    Dim readBuff(5120) As [Char]
    Dim count As Integer = streamRead.Read(readBuff, 0, 5120)

Etc...

Open in new window

0
lrbrister
Asked:
lrbrister
  • 3
  • 2
2 Solutions
 
Meir RivkinFull stack Software EngineerCommented:
Dim size as Integer = 5120
Dim readBuff(size) As [Char]

Open in new window

0
 
Luis PérezSoftware Architect in .NetCommented:
Can you please explain better what's your problem?
0
 
Meir RivkinFull stack Software EngineerCommented:
u can use a variable instead the number when u initialize the array.
0
Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

 
lrbristerAuthor Commented:
Ok guys...
So there's no dynamic setting of the number based on the Stream itself?
0
 
Meir RivkinFull stack Software EngineerCommented:
nop.
there's no Length or Size property of StreamReader
http://msdn.microsoft.com/en-us/library/system.io.streamreader_fields.aspx
if u have control of the response stream, u can decide that the 1st 4 bytes of the stream is the length.
so u read the 1st 4 bytes of the responseStream, init the array and read the rest of the stream.
0
 
lrbristerAuthor Commented:
Thanks
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now