Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Converting to Base64
Message
From
26/08/2010 09:52:25
 
 
To
26/08/2010 09:42:57
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01478537
Message ID:
01478596
Views:
21
>>Not clear how the two bits join up. IAC isn't all you really need something like this:
'Save
>>Dim lcXml As String = "<Test>Hello</Test>"
>>Dim writer As New System.IO.StreamWriter("c:\Save")
>>writer.Write(Convert.ToBase64String(System.Text.Encoding.Default.GetBytes(lcXml)))
>>writer.Close()
>>
>>'Restore
>>Dim reader As New System.IO.StreamReader("c:\Save")
>>Dim lcXmlback As String = System.Text.Encoding.Default.GetString(Convert.FromBase64String(reader.ReadToEnd()))
>>reader.Close()
>
>Here is what I have now. I have adjusted as per your code:
>
>
>        ' Convert to Base64
>        Public Function ConvertToBase64() As Boolean
>            Dim lcXml As String = ""
>            Dim llSuccess As Boolean = False
>            Dim loStreamReader As System.IO.StreamReader = Nothing
>
>            Try
>                loStreamReader = New System.IO.StreamReader(cFile)
>
>                lcXml = loStreamReader.ReadToEnd()
>
>                loStreamReader.Close()
>
>                cXML = Convert.ToBase64String(System.Text.Encoding.Default.GetBytes(lcXml))
>
>                llSuccess = True
>            Catch loError As Exception
>                cError = loError.Message
>            End Try
>
>            Return llSuccess
>        End Function
>
>        ' Convert from Base64
>        Public Function ConvertFromBase64() As Boolean
>            Dim lcXml As String = ""
>            Dim llSuccess As Boolean = False
>            Dim loStreamWriter As System.IO.StreamWriter = Nothing
>
>            Try
>                loStreamWriter = New System.IO.StreamWriter(cFile)
>
>                loStreamWriter.Write(System.Text.Encoding.Default.GetString(Convert.FromBase64String(cXML)))
>
>                loStreamWriter.Close()
>
>                llSuccess = True
>            Catch loError As Exception
>                cError = loError.Message
>            End Try
>
>            Return llSuccess
>        End Function
>
>
>Basically, at the startup, I have a a.jpg file of 28k. Once I do the reverse process, I end up a Result.jpg file of 27k. So, I need to adjust something. Basically, I believe I have the same situation as with my previous code. There is something else that need to be adjusted.

No time to look properly just now but haven't you got the process the wrong way round (i.e. the Write() param should be Convert.ToBase64String(System.Text.Encoding.Default.GetBytes......etc not GetString()....
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform