Official Content

Verifies the existence of a file on certain location.

Syntax:

FileExist(Exp)

Where:

Exp
    A string with the name and path of the file.

Type Returned:
Numeric(1)

Scope

Objects: Procedure, Transaction, Web Panel, Data Provider
Generators: .NET, .NET Framework, Java, Ruby (up to GeneXus X Evolution 3), RPG, Visual FoxPro (up to GeneXus X Evolution 3)

Description

This function receives a string as parameter, with the path and name of the file to verify. It returns 1 in case of success, and 0 otherwise.

The file search is performed in the machine where the program involing this function is executed. 

When used in Web Objects, it will be searched in the Web Server.  For the rest of the objects, in the case of C/SQL and Java, the search will be made in the processes server.

Note: It’s necessary to have reading access to the files specified in the path.

Samples

Relative path:

&file = “mydoc\docu.doc”
&res = FileExist(&File)

The relative path is taken from the default directory where the program is located.

The case &file = “C:\mydoc\docu.doc” is also of relative path, because it depends on the machine where the program is executed. For example: if it’s a Web Panel it will search the docu.doc file in the Web Server C disk, while if it’s used in a VB procedure it will be the work station C disk.

Absolute path:

&file = “\\server\c\mydoc\docu.doc”
&res = FileExist(&file)

In the case of Web Objects, the directory is determined by the Web Server, so generally it’s convenient to use absolute paths.

See Also

DeleteFile function









Last update: April 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant