Tuesday, November 9, 2010

Get the filename from the File Path using X++

AX has a standard method in the Global Class to split the file name from the entire file path.The method is fileNameSplit().The method takes filepath as the parameter.It splits the filepath into three different strings filepath,filename,fileextension respectively.The usage of the function can be seen below.

Filename filepath;
Filename filename;
Filename fileType;
str fileNameString;
;
[filepath, filename, fileType] = fileNameSplit(fileNamePath);

fileNameString= filename + fileType;

Now the fileNameString will return you the filename with extension.
I have tested this for the file path in the dialog field.It works fine.

Thanks.


3 comments: