How to Check Whether the Given Directory/ Path Exists or Not

By | January 6, 2016

In Sage X3, we may come across a situation where we need to know whether the path or a particular directory exists or not.

We can know this using following function:

Syntax: filinfo(path_fil, arg_ent)

Parameters:

path_fil: Char type expression for the file path to be tested

Arg_ent: Integer expression specifying the property to be found. It can be from 0 to 10.

Kindly refer to the below snippet of code for better understanding.

Here, we have used “7” as arg_ent (parameter) of filinfo function which gives size of file in octets.

If the file size found is negative, the file does not exist.

Check Whether the Given Directory/ Path Exists or Not

 

Here, the path defined in variable PATH is valid. Hence the output will be as follows:

Check Whether the Given Directory/ Path Exists or Not