FileExists
 
Tests the existence of a file

Syntax

Declare Function FileExists ( ByVal filename As ZString Ptr ) As Integer

Usage

#include "file.bi"
result = FileExists( filename )

or

#include "vbcompat.bi"
result = FileExists( filename )

Parameters

filename
Filename to test for existence.

Return Value

Returns non-zero (-1) if the file exists, otherwise returns zero (0).

Description

FileExists tests for the existence of a file.

Example

#include "vbcompat.bi"

Dim filename As String

Print "Enter a filename: "
Line Input filename

If FileExists( filename ) Then
  Print "File found: " & filename
Else
  Print "File not found: " & filename
End If


Platform Differences

  • Linux requires the filename case matches the real name of the file. Windows and DOS are case insensitive.
  • Path separators in Linux are forward slashes / . Windows uses backward slashes \ but it allows for forward slashes . DOS uses backward \ slashes.


Differences from QB

  • New to FreeBASIC

See also