Document Encoding.

Mar 26, 2008 at 3:56 PM
How are/do I convert the string data for a repository document back into text? So if I stored a text file in the repository and retrieved it - what would be the code to convert it back into the original text. I've tried every type of encoding to try to decode the document. Can you list some sample code to convert the encoded string back into ascii string?

Thanks.

-Charlie
Mar 26, 2008 at 4:59 PM
Try something like:

byte[] contents = Convert.FromBase64String(node.InnerText); //node is the document node
...
using (FileStream fs = new FileStream(fileName, FileMode.Create))
{
fs.Write(contents, 0, contents.Length);
}


carruda wrote:
How are/do I convert the string data for a repository document back into text? So if I stored a text file in the repository and retrieved it - what would be the code to convert it back into the original text. I've tried every type of encoding to try to decode the document. Can you list some sample code to convert the encoded string back into ascii string?

Thanks.

-Charlie

Developer
Mar 30, 2008 at 10:19 PM
That is what I was going to suggest.

This is generic enough to generate any kind of document you receive from the repository.

The only other thing I would add is to use the mime-type you receive from the RetrieveDocumentSet ot define the extension of the object, so next time you can save it. Or, if you're using a web application use the mime-type to define the mime-type header of the response, and stream the byte array back into the response. This will make IE and other browsers to open the right application straight away.

Cheers, Wagner.



e9p1 wrote:
Try something like:

byte[] contents = Convert.FromBase64String(node.InnerText); //node is the document node
...
using (FileStream fs = new FileStream(fileName, FileMode.Create))
{
fs.Write(contents, 0, contents.Length);
}


carruda wrote:
How are/do I convert the string data for a repository document back into text? So if I stored a text file in the repository and retrieved it - what would be the code to convert it back into the original text. I've tried every type of encoding to try to decode the document. Can you list some sample code to convert the encoded string back into ascii string?

Thanks.

-Charlie