Re: Read Base64 string to write a .gif (or other content type)

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hello James,

This will work for images... but will it work for other content types (ZIP, DOC, XLS)?

--
-AC [MVP MCMS]
http://www.andrewconnell.com
http://www.andrewconnell.com/mvp

Create a MemoryStream from the byte[].  Use the FromStream() and
Save() methods of System.Drawing.Image.

AC [MVP MCMS] wrote:

Hello James,

Thanks... I guess I should have been more specific.  I have that
part, converting the string to a byte array.  But for images, I've
noticed that there's a header at the start of the file (appears to be
just
plain text, but
not sure)... for example a gif has GIF[version] at the start of the
file.
I've tried writing out "GIF89a" at the start and then the byte array,
but that didn't work.  Then I tried writing the GIF89a to a separate
byte
array, write that out and then write the data stream byte array...
but that didn't work.  I've seen some examples in this NNTP about
using the BinaryWriter, and comments by Jon Skeet how that's not
necessary, but having a hard
time finding a single example of how to write this out on your own.
I'm not only interested in writing out GIF's, but also BMPs, JPEG,
PNGs, ZIPs, DOCs, XLSs, etc...

Ideas?

How 'bout System.Convert.FromBase64String ()

Home: www.noveltheory.com       Work: www.njtheater.com Blog:
www.honestillusion.com  Day Job: www.partsearch.com "AC [MVP MCMS]"
<swamplander@xxxxxxxxx> wrote in message
news:9c8265c7295518c7ba66586abce1@xxxxxxxxxxxxxxxxxxxxxxx

Any pointers on how to (1) read a Base64 encoded string from a text
file and (2) write it to a binary file?

I have a ton of files that are being generated from a legacy
system. Each file contains a (1) content type one one line, a (2)
filename, and (3) the encoding type (seems to always be Base64,
followed by the encoded string. A process will be to read the
content type and filename, then create a new binary file and write
out the converted base64 string.

Ideas?

--
-AC [MVP MCMS]
http://www.andrewconnell.com
http://www.andrewconnell.com/mvp


.



Relevant Pages

  • Re: Converting a string to an array of bytes.
    ... The user must be able to type in a string of characters that include non ... alt+159 and when converting that string to a byte array ... you would get an array with one element with the byte value 159. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: sbalneav Your Source Code
    ... > I'm not sure where you're going to store your file streams ... hence my use this array & of .txt files. ... string Blanks; ... So instead of passing the array, & converting each element. ...
    (talk.origins)
  • Re: Read Base64 string to write a .gif (or other content type)
    ... converting the string to a byte array. ... I've tried writing out "GIF89a" at the start and then the byte array, ... then create a new binary file and write out the converted ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Byte array as string?
    ... > I'm parsing ascii text in binary files. ... > file as a byte array and use StrConv then VB ... > Yet string operations would be simpler than array ... converting the file bytes to string, find the data, then ...
    (microsoft.public.vb.general.discussion)
  • Help in French|Spanish|German translation.
    ... I am also an author of User-defined string functions. ... WORDTRANEX (cSearched, cArExpressionSought | cExpressionSough, ... each string of the array is searched ... If the parameter nArStartOccurrence is -1 or omitted, the replacement starts ...
    (microsoft.public.fox.helpwanted)