local procedure ReadFiles(DirPath: Text; pXmlPort: XmlPort "Your XMLPort") var fileMgt: Codeunit "File Management"; NameValBuf: Record "Name/Value Buffer" temporary; xFile: File; InStr: InStream; begin if fileMgt.ServerDirectoryExists(DirPath) then begin fileMgt.GetServerDirectoryFilesList(NameValBuf, DirPath); if NameValBuf.FindSet() then repeat xFile.Open(NameValBuf.Name); xfile.CreateInStream(InStr); Clear(pXmlPort); pXmlPort.SetSource(InStr); pXmlPort.Filename := NameValBuf.Name; pXmlPort.Import(); xFile.Close(); until NameValBuf.Next() = 0; end else Message('Directory %1, doesn''t exists', DirPath); end;
Answers
You need to load every file to a InStream then XMLPort.SetSource(InStream) and XMLPort.Import()
Regards.
Thank you. I will try it.
Regards - Noeline
I forgot to mention, this is on-prem. The UploadIntoStream method opens a dialog asking the user to choose the file, and I don't find a way around it. My workaround has been to import with CSV Buffer instead. This does not open a dialog and uses the path and file variables, but it has certain limitations. I would prefer the xmlports if I could find a way to do a silent upload.
Regards - Noeline
You need to do something like this:
Regards