Skip to content

Instantly share code, notes, and snippets.

@d47447
Created August 7, 2019 08:43
Show Gist options
  • Select an option

  • Save d47447/0ca983178bc83b675cdbd620f29fafa4 to your computer and use it in GitHub Desktop.

Select an option

Save d47447/0ca983178bc83b675cdbd620f29fafa4 to your computer and use it in GitHub Desktop.
Create and save a csv/text file in D365FO (x++ code sample)
System.IO.Stream stream;
TextStreamIo io;
System.IO.StreamReader reader;
XML fileContent;
io = TextStreamIo::constructForWrite();
io.writeExp(str2con(<String value/record>)));
stream = io.getStream();
stream.Position = 0;
reader = new System.IO.StreamReader(stream);
filecontent = reader.ReadToEnd();
//save file on local folder
//File::SendStringAsFileToUser(str content, str fileName, System.Text.Encoding encoding = System.Text.Encoding::get_UTF8(), ClassName fileUploadStrategyClassName = classstr(FileUploadTemporaryStorageStrategy))
File::SendStringAsFileToUser(fileContent, 'MyTextFile');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment