FileExist
State = FileExist(Filename$)
 
Parameters:

    Filename$ = The name and path of the file you wish to check
Returns:

    State = 1 = file exists, 0 = file does not exist
 

The FileExist function checks if a file exists. If the requested file exists FileExist returns a true (1) value, if not a false (zero) value is returned.



FACTS:


* You can check to see if a file exists upon any device on your computer.
* The filename$ your supply FileExist can be either local or absolute.

Local files are expected to be found in the current path and might look something like this ("MyFile.txt" )

Absolute file names include the filename and the whole path ie. ("C:\\Stuff\MyFile.txt")




Mini Tutorial:


This example, check if a file exists

  
  
; Check if the file "TestFile.txt" exists
  If FileExist("TextFile.txt")=true
   ; if the file exists, the display this message
   ; to the screen
     Print "Yes, this file exists"
  Else
   ; If the file does NOT exist, then display
   ; the failure message
     Print "Nope, this does not exist"
  EndIf
  
; Display the screen and wait for a key press
  Sync
  WaitKey
  



Since it's highly unlikely theres a file called "TestFile.txt" on your computer, This example would output.

  
  Nope, this does Not exist
  

 
Related Info: CurrentDir$ | DriveExist | FolderExist :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com