Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Binary read for base 64 encoding

Posted on 2006-11-29
2
Medium Priority
?
141 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

722 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