Usina BRAdvPL Guide
Sign in
← All topics
FUNCTIONUnder review

File

File( cArquivo, [nWhere], [lChangeCase] ) --> lRet

Checks whether a file matches the specified lookup.

FileAdvPL
01 · OVERVIEW

Overview

File returns a logical result and supports wildcards, so true does not establish exactly one uniquely named file. nWhere selects server or SmartClient lookup, with path-dependent behavior for zero. Documentation excludes hidden/system files and describes JOB limitations for workstation paths. This example uses nWhere=1 and a fictional drive-free name without opening, creating or guaranteeing exclusive access. (TOTVS, n.d., ref. 1)

02 · SYNTAX

Syntax

File( cArquivo, [nWhere], [lChangeCase] ) --> lRet

Parameters

cArquivo
CharacterRequired

Filename or mask.

nWhere
NumericOptional

0 depends on path; 1 server; 2 SmartClient.

lChangeCase
LogicalOptional

Filename case handling according to build/configuration.

Return value

Logical file lookup result.

03 · PRACTICAL EXAMPLE

Commented example

#Include "Protheus.ch"
#Include "Fileio.ch"

User Function Ed386()
    // Server lookup without assuming the test file exists.
    ConOut(cValToChar(File("editorial-test.txt", 1, .F.)))
Return Nil
Expected result

True or false according to file/context; does not prove write permission. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

BEST PRACTICES
  • Check path, permissions, platform and handle ownership. Close only handles obtained by this routine, including complete-application error handling.
  • Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Related content

REFERENCES
  1. TOTVS. File. TDN. Accessed on 2026-10-26.
Status
Under review
Page created on
Last reviewed on
Original language
Portuguese
Reviewed by
Usina.BR
0 approved comment(s)

Comments

There are no approved comments yet.

Sign in with Google or Microsoft to comment.

Powered by Usina Docs · Alpha