Problem in Base64 encoding and decoding in C?

You're not reading the data - you're just creating a byte array of the appropriate length and then converting that array of zeroes into base 64.

You're not reading the data - you're just creating a byte array of the appropriate length and then converting that array of zeroes into base 64. Use File. ReadAllBytes to read a file into memory completely in a very simple way... or if you really want to do it by hand, loop round reading the data into the buffer - you shouldn't rely on a single call to Stream.

Read to read everything. If you want to write binary data, use File. WriteAllBytes, and to write text, use File.WriteAllText.

Even when you've managed to write out the base64 data though, you won't be able to open it as in Word - because it's just a text file of base64 text... you either want to write out the decoded binary data, or you want to write the base64 data out to something which will then decode it later. (Currently you're just throwing away the decoded data. ) Finally, not that in times where you do use a StreamWriter, you should use a using statement to make sure it's disposed even if it throws an exception.

Thanks dude.... its working now.......... – Pradeep Sep 29 '10 at 6:44.

You're not reading the data, and you're also writing the Base64 data, not the decoded binary.

If you are intending to actually copy the content, it would be a whole lot easier by using System.IO.File.Copy() method.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions