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

x
?
Solved

Binary read for base 64 encoding

Posted on 2006-11-29
2
Medium Priority
?
142 Views
Last Modified: 2010-04-23
hello,

Using vb.net I need to read a file (whos path i kno) and convert the file into base 64 encoding within an xml node. Thus far I have attempted the following where cFile is the path of the file


            fs = New FileStream(cFile, FileMode.Open, FileAccess.Read)
            fs.Read(bytes, 0, bytes.Length)
             str64 = Convert.ToBase64String(bytes)

then putting it into xml

If cFile <> Nothing Then
                objField = objDOM.createElement("MSGFILE")
                objField.dataType = "bin.base64"
                objField.nodeTypedValue = str64
                objRow.appendChild(objField)
End If

but receive the folowing error:

Procedure call or argument is not valid.

thanks.

0
Comment
Question by:wdhough
2 Comments
 
LVL 13

Accepted Solution

by:
newyuppie earned 500 total points
ID: 18036522
in which line is the error?
0
 

Author Comment

by:wdhough
ID: 18036995
not to worry problem sorted :

solution:

Dim s As String
            Dim f As New System.IO.FileStream(cFile, IO.FileMode.Open, IO.FileAccess.Read)
            Dim b(f.Length) As Byte
            f.Read(b, 0, f.Length)
            s = Convert.ToBase64String(b)
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Integration Management Part 2
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

963 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question