function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
asadimasadim 

Decoding Attachments back to original format

Hi,

 

I have a Word document uploaded as an Attachment. When I query for this file in my code (using SforceOfficeToolkit) I get back an Attachment sobject from which I can access its blob (body). I believe the blob is encoded in Base64. To convert this blob back into the original Word format I use a Base64 decoder. The decoder doesn't work with documents that have headers/footers but it works otherwise.

 

Any ideas how to get this to work? Here's my decoder just in case:

 

 

        public static byte[] DecodeBase64(string b64)
        {
            MSXML2.DOMDocument objXML = new MSXML2.DOMDocument();
            MSXML2.IXMLDOMElement objNode = objXML.createElement("b64");
            objNode.set_dataType("bin.base64");
            objNode.text = b64;
            return (byte[])objNode.nodeTypedValue;
        }

 

Thanks!