Merge a string doesn't work

V

vodafone

I've some problems while merging a string retrieved from a stream and
re-built with the encoding.

To be short. The first time string will be concatenated, all works
fine, from the second time, it get only the first string ... the second
part won't never added, and I really don't understand the reason.
Obviously I'm working on vb.net

This is the code.

Dim fi As New FileInfo("g:\x.txt")

Dim mStream As Stream = fi.Open(FileMode.Open, FileAccess.Read)

Dim nBytes As Integer = 256
Dim ByteArray(nBytes) As Byte

Dim [encoding] As System.Text.Encoding = encoding.ASCII
Dim regExp As New Regex("\n")

Dim lastIdx As Int32
Dim ByteRead As Int32 = 0
Dim appo As String = "bye bye "
Dim s As String

Do
ByteRead = mStream.Read(ByteArray, 0, nBytes)
s = appo + [encoding].GetString(ByteArray)

Dim m As Match = regExp.Match(s.ToString)

Do While m.Success
Dim g As Group = m.Groups(0)

Dim tmp As String = (s.Substring(lastIdx, g.Index - lastIdx))
Console.WriteLine(tmp)

lastIdx = g.Index + 1
m = m.NextMatch
Loop

appo = s.Substring(lastIdx)
Loop While (ByteRead > 0)

Somebody can suggest me how to solve, and why my code won't work?

Thanks
Andrea
 
V

vodafone

I tried also in this way ....

Dim mStream As New StreamReader("g:\x.txt")
Dim ByteArray(nBytes) As Char
Dim s as new StringBuilder

Do
s.Remove(0, s.Length)
s.Append(appo + New String(ByteArray))
....
Loop while mycondition = true

It sounds like string concatenation isn't allowable when in the new
string an array of byte or array of char takes place.

I don't believe it!

Where's my error?

Andrea
 
D

Doug Bell

No response could have something to do with the contempt vodaphone company
shows its customers.
You might try changing your name.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top