Thx you all for the responses
I have decided to go with Abubakar's suggestions and, for the future
reference, this is a simple function that does what I need
//--------------------------------------------------------------------------------
private string Base64Decode(string data, string fileName)
{
FileStream fs = new FileStream(fileName, FileMode.OpenOrCreate,
FileAccess.Write);
int sizeOfChunk = 4;
int startPosition = 0;
while (startPosition < data.Length)
{
string tmp = data.Substring(startPosition, sizeOfChunk);
startPosition = startPosition + sizeOfChunk;
byte[] tmpArr = Convert.FromBase64String(tmp);
fs.Write(tmpArr, 0, tmpArr.Length);
}
fs.Close();
fs.Dispose();
return fileName;
}
//--------------------------------------------------------------------------------
Abubakar wrote:
Hi,
I dont know about the directly decoding it to file, but you could read fixed
chunks in sizes which should be multiple of 4 (in a loop) and convert and
write them to the destination file (i have used the chunk size of 4):
something like the following code (its just using a textbox but u can use
filestream of course);
string base64text = textBox2.Text;
int startingindex = 0;
txttranslated.Clear(); // destination textbox
while (startingindex<base64text.Length)
{
string tmp = base64text.Substring(startingindex, 4);
startingindex += 4;
txttranslated.AppendText (Encoding.ASCII.GetString (
Convert.FromBase64String(tmp)));
}
hope that help ..
Regards,
..ab
<se************@gmail.comwrote in message
news:11**********************@v45g2000cwv.googlegr oups.com...
I am getting a huge file attachment from SWA web service, obviously in
Base64. Is there a way to decode the Base64 string directly to a file
(FileStream or similar) instead to byte array?