Solved

Binary read for base 64 encoding

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
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.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

829 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