将AX 2012中附件的内容复制到特定记录

时间:2013-01-07 10:02:32

标签: axapta x++ dynamics-ax-2012 ax

我需要以任何形式将附件的内容复制到AX2012中的特定记录,然后我必须将此内容粘贴到相同表单下的任何字符串类型字段中。

我正在尝试执行此操作:

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

    TextIo txIoRead,
         txIoWrite;
    FileIOPermission fioPermission;
    TextBuffer txtb;
    container containFromRead;
    int xx,num,
        iConLength;
    str sTempPath,
        sFileName, completename ;
    str 64 s1;
    ;
   Dev_ManageTemplates_ds.getFirst(true);
    recid = Dev_ManageTemplates.RecId;

   select obj_docuRef
        where obj_docuRef.RefRecId == recid;

    select obj_DocuValue
        where obj_DocuValue.name == 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();
    fioPermission.assert();
    txtb.fromFile("completename"); // Read text from file
    //txtb.toString(); // Copy it to the clipboard
   // StringEdit.text(txtb.getText());
    s1 = txtb.getText();
   // info(txtb.getText());

}

1 个答案:

答案 0 :(得分:2)

阅读代码时,错误很明显:

new FileIoPermission("completename",'r').assert();
txtb = new TextBuffer();
txtb.fromFile("completename"); 

应该是:

new FileIoPermission(completename,'r').assert();
txtb = new TextBuffer();
txtb.fromFile(completename); 

此外,在AX中使用Hungarian Notation不是Best Practice