how to encode/decode files like outlook

  • Thread starter Abraham Andres Luna
  • Start date
A

Abraham Andres Luna

can anyone point me to a tutorial on how to encode files like outlook
encodes attachments
i want to encode all the attachments and save it to an sql table. then
decode when i need it. thank you.
 
D

Daniel O'Connell [C# MVP]

Abraham Andres Luna said:
can anyone point me to a tutorial on how to encode files like outlook
encodes attachments
i want to encode all the attachments and save it to an sql table. then
decode when i need it. thank you.

Well, email attachments are encoded using Base64, which
Convert.ToBase64String() and convert.FromBase64String() can handle for you.

But can't some SQL column types handle raw bytes? And is it wise to be
storing file data in a database instead of just a reference?
 
A

Abraham Andres Luna

ty for your answer, it is exactly what i needed


Daniel O'Connell said:
Well, email attachments are encoded using Base64, which
Convert.ToBase64String() and convert.FromBase64String() can handle for
you.

But can't some SQL column types handle raw bytes? And is it wise to be
storing file data in a database instead of just a reference?
 
A

Abraham Andres Luna

does the capital J and lowercase j have different meanings?
would i be able to uppercase the string and have it not affect anything?
 
J

Jon Skeet [C# MVP]

Abraham Andres Luna said:
does the capital J and lowercase j have different meanings?
Yes.

would i be able to uppercase the string and have it not affect anything?

No. Base64 gets its 64 different characters using A-Z, a-z, 0-9, + and
/. Uppercasing the string would change the encoded binary data
drastically.
 
R

Richard Grimes

Daniel said:
Well, email attachments are encoded using Base64, which
Convert.ToBase64String() and convert.FromBase64String() can handle
for you.

Bear in mind that these routines are not particularly efficient (they
make lots of unnecessary allocations) and they do not provide a facility
to add a newline at character position 76 as per the RFC. This means
that if you want to add newlines you have to make yet more allocations
as you copy sections of the base64 encoded string to another string.

I have written a series of classes that implements base64, yenc and uu
encoding as stream objects with minimal buffering so they are far more
efficient and they have more options than the built in .NET routines.

Email me if you want me to post them on my site.

Richard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top