Oxygen Basic
Programming => Problems & Solutions => Topic started by: chrisc on April 25, 2018, 04:08:15 AM
-
Hello
i need a function to determine whether a folder exist or a code example that uses
PathFileExists function
can someone help on this? appreciate all help
-
in PB we have a function like this below, would need an O2 equivalent
'======================================
' check if folder exist
FUNCTION FolderExists(BYVAL FolderSpec AS STRING) EXPORT AS LONG
FUNCTION = %FALSE
IF ISTRUE PathFileExists(BYVAL STRPTR(FolderSpec)) THEN
FUNCTION = %TRUE
EXIT FUNCTION
END IF
END FUNCTION
-
Hi Chris,
This page lists all the file management functions
https://msdn.microsoft.com/en-us/library/windows/desktop/aa364232(v=vs.85).aspx
I would suggest using FindFirstFile
uses corewin
function FileExists(char*fi) as int
===================================
WIN32_FIND_DATA fd
sys h
h=FindFirstFile fi,fd
if h>0 then
FindClose h
return 1
end if
end function
print FileExists("t.o2bas") 'file
print FileExists("ChrisC") 'folder
-
Thanxx a lot Charles