Ask a Question related to ASP.NET General, Design and Development.
-
PCH #1
base64 enc/dec problem
I'm having a problem encoding a file (image) into base64, and then
converting it back from base64 and saving it.
I've tried several ways, but whenever i open the new image.. it is always
corrupt.
Here is the base coding I'm trying to get working
Imports System.IO
Dim fs As FileStream
Dim fswrite As FileStream
Dim oByte() As Byte
fs = New System.IO.FileStream("C:\18.jpg", _
System.IO.FileMode.Open, _
System.IO.FileAccess.Read)
ReDim oByte(fs.Length)
Dim b64String As String
b64String = System.Convert.ToBase64String(oByte, 0, fs.Length)
fswrite = File.Create("C:\test1.jpg", 1024)
Dim info As Byte() = New UTF8Encoding(True).GetBytes(b64String)
fswrite.Write(info, 0, info.Length)
fswrite.Close()
fs.Close()
PCH Guest
-
Base64.Encode in AS1
Hi, know i know chances are really slim on this one but i'm currently working with a Base64 encdoing in AS2. Now its not my original code which... -
Problem with Base64 encoding a MS Word Document
I am trying to Base64 encode a MS Word document on CF 7. However, when I try to decode and save the file and open it in word, it only shows raw... -
Java Base64 encoding
When I specify a username and password within a CFHTTP tag does Cold Fusion automatically Java Base64 encode these values or is it something you... -
decoding a base64 file?
Hello folks, If I encode a file with MIME::Base64 with the following script, encode_base64.pl. The question is; how do I decode the file? I... -
base64 code
Hi Alan, Thanks for your help. Also I know for a fact my client is not a spammer! But thanks for the warning anyway! "Alan Ames"... -
David Browne #2
Re: base64 enc/dec problem
"PCH" <pch12@hotmail.com> wrote in message
news:Omaoeb$PDHA.704@tk2msftngp13.phx.gbl...First you were never reading the input file. Second you were saving the> I'm having a problem encoding a file (image) into base64, and then
> converting it back from base64 and saving it.
>
> I've tried several ways, but whenever i open the new image.. it is always
> corrupt.
>
base64 encoded string to the output file. Here:
Dim fs As FileStream
Dim fswrite As FileStream
Dim oByte() As Byte
fs = New System.IO.FileStream("C:\18.jpg", _
System.IO.FileMode.Open, _
System.IO.FileAccess.Read)
ReDim oByte(fs.Length)
fs.Read(oByte, 0, fs.Length)
Dim b64String As String
b64String = System.Convert.ToBase64String(oByte, 0, fs.Length)
fswrite = File.Create("C:\test1.jpg", 1024)
Dim info As Byte() = System.Convert.FromBase64String(b64String)
fswrite.Write(info, 0, info.Length)
fswrite.Close()
fs.Close()
David
David Browne Guest
-
PCH #3
Re: base64 enc/dec problem
ah that Read call!
fs.Read(oByte, 0, fs.Length)
Thanks for the info!
"David Browne" <davidbaxterbrowne no potted [email]meat@hotmail.com[/email]> wrote in
message news:%23wydej$PDHA.3880@tk2msftngp13.phx.gbl...always>
> "PCH" <pch12@hotmail.com> wrote in message
> news:Omaoeb$PDHA.704@tk2msftngp13.phx.gbl...> > I'm having a problem encoding a file (image) into base64, and then
> > converting it back from base64 and saving it.
> >
> > I've tried several ways, but whenever i open the new image.. it is> First you were never reading the input file. Second you were saving the> > corrupt.
> >
> base64 encoded string to the output file. Here:
>
> Dim fs As FileStream
> Dim fswrite As FileStream
> Dim oByte() As Byte
> fs = New System.IO.FileStream("C:\18.jpg", _
> System.IO.FileMode.Open, _
> System.IO.FileAccess.Read)
> ReDim oByte(fs.Length)
> fs.Read(oByte, 0, fs.Length)
> Dim b64String As String
> b64String = System.Convert.ToBase64String(oByte, 0, fs.Length)
> fswrite = File.Create("C:\test1.jpg", 1024)
> Dim info As Byte() = System.Convert.FromBase64String(b64String)
> fswrite.Write(info, 0, info.Length)
> fswrite.Close()
> fs.Close()
>
> David
>
>
PCH Guest



Reply With Quote

