copy contents of attached file in AX 2012 to a particular record

I need to copy the contents of a attached file to a particular record in AX2012 in any form and then I have to paste this content in any string type field under same form.

I am trying to perform this as:

public void getdocucontent()
    Dev_ManageTemplates obj_Dev_ManageTemplates;
    DocuRef obj_docuRef;
    DocuValue obj_DocuValue;
    RecId recid;

    TextIo txIoRead,
    FileIOPermission fioPermission;
    TextBuffer txtb;
    container containFromRead;
    int xx,num,
    str sTempPath,
        sFileName, completename ;
    str 64 s1;
    recid = Dev_ManageTemplates.RecId;

   select obj_docuRef
        where obj_docuRef.RefRecId == recid;

    select obj_DocuValue
        where == obj_docuRef.Name;

    sTempPath = obj_docuRef.path();
    sFileName = obj_DocuValue.FileName;
    completename = sTempPath+sFileName+"."+obj_DocuValue.FileType;

   fioPermission = new FileIoPermission("completename",'r');
   txtb = new TextBuffer();
    txtb.fromFile("completename"); // Read text from file
    //txtb.toString(); // Copy it to the clipboard
   // StringEdit.text(txtb.getText());
    s1 = txtb.getText();
   // info(txtb.getText());