|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
vb.net code for inserting vbcrlf every 80 charactersstream, 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).resourceObject.URL.value) 'This pulls in the image as a byte() Dim base64String As String = Convert.ToBase64String(bytes) Return base64String End Function 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 <tom.kr***@gbmail.com> wrote in message Show quote news:1157736203.517822.40020@b28g2000cwb.googlegroups.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).resourceObject.URL.value) 'This > pulls in the image as a byte() > Dim base64String As String = Convert.ToBase64String(bytes) > > Return base64String > End Function > 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 <tom.kr***@gbmail.com> wrote in message Show quote news:1157736203.517822.40020@b28g2000cwb.googlegroups.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).resourceObject.URL.value) 'This > pulls in the image as a byte() > Dim base64String As String = Convert.ToBase64String(bytes) > > Return base64String > End Function > |
|||||||||||||||||||||||