how to check if a file exist?

Just starting out? Need help? Post your questions and find answers here.
bernardfrancois
User
User
Posts: 47
Joined: Tue Sep 02, 2003 9:17 am
Location: Belgium
Contact:

how to check if a file exist?

Post by bernardfrancois »

hello,

does anyone know how I can check if a file exists?

greetz,

Bernard
LarsG
Enthusiast
Enthusiast
Posts: 713
Joined: Mon Jun 02, 2003 1:06 pm
Location: Norway
Contact:

Post by LarsG »

oops... sorry.. misread the docs.. :lol:
I suggested Openfile(), but it will create a file if it doesn't exist..
but you can use ReadFile() I guess?!?

[edit for the n'th time :roll: ] .. or you can go for Berikco's code below.. [/edit]
Last edited by LarsG on Tue Feb 17, 2004 1:54 pm, edited 2 times in total.

AMD Athlon XP2400, 512 MB RAM, Hercules 3D Prophet 9600 256MB RAM, WinXP
PIII 800MHz, 320 MB RAM, Nvidia Riva Tnt 2 Mach 64 (32MB), WinXP + Linux
17" iMac, 1.8 GHz G5, 512 MB DDR-RAM, 80 GB HD, 64 MB Geforce FX 5200, SuperDrive, OSX
Berikco
Administrator
Administrator
Posts: 1326
Joined: Wed Apr 23, 2003 7:57 pm
Location: Belgium
Contact:

Post by Berikco »

Code: Select all

If FileSize(FileName$) > -1 ; file exist

Endif
bernardfrancois
User
User
Posts: 47
Joined: Tue Sep 02, 2003 9:17 am
Location: Belgium
Contact:

Post by bernardfrancois »

bedankt / merci :)
Berikco
Administrator
Administrator
Posts: 1326
Joined: Wed Apr 23, 2003 7:57 pm
Location: Belgium
Contact:

Post by Berikco »

LarsG wrote:oops... sorry.. misread the docs.. :lol:
I suggested Openfile(), but it will create a file if it doesn't exist..
but you can use ReadFile() I guess?!?

[edit for the n'th time :roll: ] .. or you can go for Berikco's code below.. [/edit]
@LarsG: ROFLMAO Image
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

i guess everybody expects an if exist() function... :-)

so did i :oops:
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
Post Reply