0

I am exporting a csv file from Ax 2012.

The path to store Eg:"D:\Local\folder" is coming from a field in Ax 2012.

Now I have created a new file. Eg:Cust.csv, and wrote my values from a container to the file.

The problem is how to store the file in the system to the folder path specified above.

I am using Runbasebatch, is it same while execting on server side.

Thanks,

Vivek Chirumamilla

1 Answers1

3

In the old days (before AX 2012) you would use WinAPI::moveFile() to move the file en place, but it does not work when running CIL (it is client only).

.Net comes to rescue:

new InteropPermission(InteropKind::ClrInterop).assert(); // get dll interop permission
System.IO.File::Move(fileName, newFileName);

You will have to construct the newFileName from your field beforehand.

But why not create the file there in the first place?

Jan B. Kjeldsen
  • 17,817
  • 5
  • 32
  • 50