Checking if a file exists.
One of the most asked for topics.

This is: When you open a file that doesn't exist in BINARY mode, it creates one new. If it has happened, if we look its LOF (file length) it equals zero, so we know that the file didn't exist and we only have to close it and kill it. In other words:


' Check if FOO.TXT exists:
OPEN "FOO.TXT" FOR BINARY AS #1
IF LOF(1)=0 THEN
' File didn't exist, so...
CLOSE #1
KILL "FOO.TXT"
ELSE
' File does exist, so...
CLOSE #1
'now do whatever you like, now that you know that the file exists.
[...]
ENDIF


I hope this clarifies the whole thing.
na_th_an


FileExists - page last edited 2004-01-01 18:23:54 by 81.203.196.133 (home) (edit)
Blast WIKI - by RoboticBoy - edited and tweaked for our evil purposes by Hexadecimal Disaster