Solved

Binary read for base 64 encoding

Posted on 2006-11-29
2
134 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 250 total points
Comment Utility
in which line is the error?
0
 

Author Comment

by:wdhough
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

744 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now