468,272 Members | 2,101 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,272 developers. It's quick & easy.

vb.net code for inserting vbcrlf every 80 characters

Here's the thing. I am downloading a tiff image through an http
stream, then I am converting it to a byte array, then I convert it to a
string which I place in an XML file. When I place the string in the
xml file it is super long (slows down all editors when opening), so I
was thinking to insert vbCrLf every 80 characters or so but I don't
want to slow down my program that creates the XML file. I was
wondering the best way to accomplish that. Here is my current code:

xmlWriter.WriteString(getBase64Document(loan))

Private Function getBase64Document(ByVal loan As MtgLoan) As String
Dim httpStream As System.Net.WebClient = New Net.WebClient()
Dim bytes As Byte() =
httpStream.DownloadData(loan.ICMBASE(0).resourceOb ject.URL.value) 'This
pulls in the image as a byte()
Dim base64String As String = Convert.ToBase64String(bytes)

Return base64String
End Function

Sep 8 '06 #1
3 2448
Tom,

I'm more C# than VB... but I did do a lot of VB6 so I'll just wing it
(strings in vb.net begin at 0... right?):

Dim i as Integer
Dim f as String

f = ""
For i = 0 to len(Base64String) - 1 step 80 :
f = f & mid(Base64String, i, 80) & vbCrLf
Next i
Regards,

Rob

<to*******@gbmail.comwrote in message
news:11*********************@b28g2000cwb.googlegro ups.com...
Here's the thing. I am downloading a tiff image through an http
stream, then I am converting it to a byte array, then I convert it to a
string which I place in an XML file. When I place the string in the
xml file it is super long (slows down all editors when opening), so I
was thinking to insert vbCrLf every 80 characters or so but I don't
want to slow down my program that creates the XML file. I was
wondering the best way to accomplish that. Here is my current code:

xmlWriter.WriteString(getBase64Document(loan))

Private Function getBase64Document(ByVal loan As MtgLoan) As String
Dim httpStream As System.Net.WebClient = New Net.WebClient()
Dim bytes As Byte() =
httpStream.DownloadData(loan.ICMBASE(0).resourceOb ject.URL.value) 'This
pulls in the image as a byte()
Dim base64String As String = Convert.ToBase64String(bytes)

Return base64String
End Function

Sep 9 '06 #2
Tom,

My previous message... I was doing simple concatenation... "f = f & mid(f,
...) & f"... well that really should be done using a string builder. String
builder is much more efficient than regular strings for this exact sort of
algorithm.

Doh!!

Regards,

Rob
<to*******@gbmail.comwrote in message
news:11*********************@b28g2000cwb.googlegro ups.com...
Here's the thing. I am downloading a tiff image through an http
stream, then I am converting it to a byte array, then I convert it to a
string which I place in an XML file. When I place the string in the
xml file it is super long (slows down all editors when opening), so I
was thinking to insert vbCrLf every 80 characters or so but I don't
want to slow down my program that creates the XML file. I was
wondering the best way to accomplish that. Here is my current code:

xmlWriter.WriteString(getBase64Document(loan))

Private Function getBase64Document(ByVal loan As MtgLoan) As String
Dim httpStream As System.Net.WebClient = New Net.WebClient()
Dim bytes As Byte() =
httpStream.DownloadData(loan.ICMBASE(0).resourceOb ject.URL.value) 'This
pulls in the image as a byte()
Dim base64String As String = Convert.ToBase64String(bytes)

Return base64String
End Function

Sep 9 '06 #3
tom
Okay I actually changed my code so that it processes even quicker now.
I would still like vbCrLf every 80 characters or so, and I tried a
couple methods and they are super slow. Any other ideas on a quick
running solution? Here is the code I use now...
Dim httpStream as system.net.webclient = new net.webclient()
dim bytes as byte() =
httpstream.downloaddata(loan.icmbase(0).resourceob ject.URL.value)
xmlWriter.WriteBase64(bytes, 0, bytes.Length)

So now instead of sticking it in a string I buffer it from bytes
straight to file.

Rob MacFadyen wrote:
Tom,

My previous message... I was doing simple concatenation... "f = f & mid(f,
..) & f"... well that really should be done using a string builder. String
builder is much more efficient than regular strings for this exact sort of
algorithm.

Doh!!

Regards,

Rob
<to*******@gbmail.comwrote in message
news:11*********************@b28g2000cwb.googlegro ups.com...
Here's the thing. I am downloading a tiff image through an http
stream, then I am converting it to a byte array, then I convert it to a
string which I place in an XML file. When I place the string in the
xml file it is super long (slows down all editors when opening), so I
was thinking to insert vbCrLf every 80 characters or so but I don't
want to slow down my program that creates the XML file. I was
wondering the best way to accomplish that. Here is my current code:

xmlWriter.WriteString(getBase64Document(loan))

Private Function getBase64Document(ByVal loan As MtgLoan) As String
Dim httpStream As System.Net.WebClient = New Net.WebClient()
Dim bytes As Byte() =
httpStream.DownloadData(loan.ICMBASE(0).resourceOb ject.URL.value) 'This
pulls in the image as a byte()
Dim base64String As String = Convert.ToBase64String(bytes)

Return base64String
End Function
Sep 19 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Jurjen de Groot | last post: by
18 posts views Thread by Joe Fallon | last post: by
5 posts views Thread by Drygast | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.