Kbase P19725: How to check if a file exists and is accessible before attempting to use it
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  25/01/2005 |
|
Status: Unverified
GOAL:
How to check if a file exists and is accessible (permissions) before attempting to use it.
GOAL:
This can be used to trap errors with the INPUT statement before they occur.
FACT(s) (Environment):
Progress 9.x
FIX:
With some statements (e.g. INPUT) NO-ERROR cannot be used, so when attempting to reference an external file or directory, if the file or directory does not exist, or does not have the correct access permissions, this can result in the 293 error:
File was not found (293)
This can be worked around using OS-COMMAND to execute various OS commands, but this can be long winded.
Use the FILE-TYPE attribute of the FILE-INFO handle to determine if the directory or file exists and also its accessibility. e.g.
FILE-INFO:FILENAME = ("C:\temp").
IF(INDEX(FILE-INFO:FILE-TYPE, "R") = 0) THEN DO:
etc .....