Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

directory exists

104 views
Skip to first unread message

aurora baccio

unread,
Feb 23, 2021, 11:38:46 AM2/23/21
to
good evening,
I must be sure that a directory has been created.
Is there a command to search like if (if the path exists) then (if the path does not exist) endif ? ?
Thanks always
Aurora Baccio

JohnMartens

unread,
Feb 23, 2021, 11:54:58 AM2/23/21
to
Hope this can help

John

FUNCT IsDir( cDirectory AS STRING ) AS LOGIC
LOCAL lRetVal := TRUE AS LOGIC
LOCAL StruData IS _WINWIN32_FIND_DATA
LOCAL nHandle AS PTR
DO CASE
CASE Empty(cDirectory)
lRetVal := FALSE
CASE ! SubStr(cDirectory,2,2) == ':\'
* see if you want full path or not
CASE IsDriveReady(Left(cDirectory,2))
* the drive of the path is not ready
OTHERWISE
lRetVal := FALSE
ENDCASE
*
* check dir on the drive
IF lRetVal
IF !( Right( cDirectory, 1 ) == "\" )
cDirectory += "\"
ENDIF

nHandle := FindFirstFile( String2Psz( cDirectory+'*.*' ), @StruData )
IF nHandle = INVALID_HANDLE_VALUE
lRetVal := FALSE
ELSE
CloseHandle( nHandle )
lRetVal := TRUE
ENDIF
ENDIF
RETURN lRetVal



Op 23-2-2021 om 17:38 schreef aurora baccio:

aurora baccio

unread,
Feb 23, 2021, 1:06:44 PM2/23/21
to
thanks,it works
Aurora Baccio

Wolfgang Riedmann

unread,
Feb 24, 2021, 7:52:35 AM2/24/21
to
Or even easier:


function IsDirectory( cFileName as string ) as logic
local nReturn as dword

if Right( cFileName, 1 ) == "\"
cFileName := Left( cFileName, SLen( cFileName ) - 1 )
endif
nReturn := GetFileAttributes( String2Psz( cFileName ) )
if nReturn == 0xFFFFFFFF
return false
endif

return _And( nReturn, FILE_ATTRIBUTE_DIRECTORY ) ==
FILE_ATTRIBUTE_DIRECTORY

Wolfgang
--

Fred Killet

unread,
Feb 25, 2021, 11:47:51 AM2/25/21
to
Function isPath(cPath)
RETURN ALen(Directory(cPath + "*.*"," D")) > 0

Fred

Fred Killet

unread,
Feb 27, 2021, 3:45:19 AM2/27/21
to
Funktioniert unter VO28 mit und ohne abschließenden Backshlash. Die
Funktion Directory() korrigiert den Path-String offensichtlich
selbstständig.
0 new messages