Hi all,
when am trying to invoke the file from file server and convert it to the bytes or container in ax 2012 using code, the below error occurs.
Error executing code: Binary (object), method
constructionFromMemoryStream called with invalid parameters.
The code am trying is
System.IO.FileStream fileStream;
System.IO.MemoryStream memoryStream;
PurchTable purchTable;
DocuRef docuRef;
DocuValue docuValue;
Filename fileName;
container con;
int size;
FilePath filePath = @"D:\DocumentManagement";
purchTable = PurchTable::find("purchid");
select * from docuRef
where docuRef.RefTableId == tableNum(PurchTable)
&& docuRef.RefRecId == purchTable.RecId
&& docuRef.RefCompanyId == curext();
docuValue = DocuValue::find(docuRef.ValueRecId);
fileName = "D:\\DocumentManagement\\" + docuValue.FileName + "." + docuValue.FileType;
fileStream = System.IO.File::OpenRead(filename);
memoryStream = new System.IO.MemoryStream();
size = filestream.get_Length();
memoryStream.SetLength(size);
fileStream.Read(memoryStream.GetBuffer(), 0, size);
con = Binary::constructFromMemoryStream(memoryStream).getContainer();
fileStream.Close();
Thanks in advance,
K. Vigneshvaran

Report
All responses (
Answers (