Author Topic: need a function to determine whether a folder exist  (Read 1234 times)

0 Members and 1 Guest are viewing this topic.

chrisc

  • Guest
need a function to determine whether a folder exist
« 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

chrisc

  • Guest
Re: need a function to determine whether a folder exist
« Reply #1 on: April 25, 2018, 04:14:26 AM »
in PB we have a function like this below, would need an O2 equivalent

Code: [Select]
'======================================
' 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

Charles Pegge

  • Guest
Re: need a function to determine whether a folder exist
« Reply #2 on: April 25, 2018, 06:17:32 AM »
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

Code: [Select]
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

« Last Edit: April 25, 2018, 06:31:14 AM by Charles Pegge »

chrisc

  • Guest
Re: need a function to determine whether a folder exist
« Reply #3 on: April 25, 2018, 08:03:31 AM »
Thanxx a lot Charles