Problems with EXISTS using Mapped Drive

Hi there!,

I have an issue using the EXISTS procedure with a path that includes a network drive (can’t find the path), is there an alternative way?

CWUtil.clw has FileExists() that uses API FindFirstFile(). You could try calling API GetFileAttributes().

Neither of these is probably going to work if there is no network connection to the server. I used to ShellExecute to open the folder in Windows Explorer and it would connect.

FileExists         PROCEDURE ( STRING sFile )

bRetVal            BYTE,AUTO
hFindHandle        SIGNED,AUTO
szFindFile         CSTRING(FILE:MaxFileName),AUTO
gFileFind          LIKE (WIN32_FIND_DATA),AUTO

  CODE
  hFindHandle = 0
  bRetVal     = FALSE
  szFindFile  = CLIP (sFile)
  CLEAR (gFileFind)

  hFindHandle = FindFirstFile (szFindFile, gFileFind)
  bRetVal = CHOOSE (NOT (hFindHandle = INVALID_LONG_VALUE OR hFindHandle <= 0))

  FindClose (hFindHandle)
  RETURN bRetVal
2 Likes

Thanks Carl! Very Useful!