FileExists?
BlitzMax Forums/BlitzMax Programming/FileExists?
| ||
Am I being dumb (again)? But BMax doesn't seem to have a simple command to see if a file exists, so I made this:Function ccFileExists%(filename$) Local file:TStream=OpenFile(filename) If file Then CloseStream file Return 1 Else Return 0 EndIf End Function |
| ||
FileType is the simple command for fileexist check. |
| ||
Yup - FileType returns 0 for doesn't exist, 1 is a file, 2 is a folder. Same as in Blitz3D, I think. Better to check for FileType() = 1, rather than FileType() <> 0, otherwise you could potentially end up trying to carry out file operations on a folder, which will cause errors. |
| ||
aha, good info thanks. |