Solved

Binary read for base 64 encoding

Posted on 2006-11-29
2
138 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 250 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

Independent Software Vendors: 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

Suggested Solutions

Title # Comments Views Activity
vb.net 1 month apart 11 39
Help with error in Query 2 39
Retrieve Active Directory Groups a User belongs to in VB.NET 3 43
Create a button class for use in all vb.net apps 5 14
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.

762 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