P
PCH
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()
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()