Hello friends,
In some of our recent projects, we encountered issues with file-based applications running over network drives โ especially when the connection was temporarily lost (e.g. via WLAN, sleeping NAS, or Windows caching).
A standard FILE() check often fails in these cases, even though the file is still accessible (e.g. cached or available again after a few seconds).
To address this, weโve created a small helper function that combines DIRECTORY() and FILE() to check both network availability and file existence more reliably.
Ensure safe .DBF access in less stable network environments
Prevent unwanted file creation due to false negatives from FILE()
Optionally integrate logging or user feedback
Best regards,
Otto
In some of our recent projects, we encountered issues with file-based applications running over network drives โ especially when the connection was temporarily lost (e.g. via WLAN, sleeping NAS, or Windows caching).
A standard FILE() check often fails in these cases, even though the file is still accessible (e.g. cached or available again after a few seconds).
To address this, weโve created a small helper function that combines DIRECTORY() and FILE() to check both network availability and file existence more reliably.
Ensure safe .DBF access in less stable network environments
Prevent unwanted file creation due to false negatives from FILE()
Optionally integrate logging or user feedback
Best regards,
Otto
FUNCTION SafeFileExists( cPath )
// First, check if the network path responds
IF empty( DIRECTORY( cPath ) )
RETURN .F.
ENDIF
// Then check if the file really exists
RETURN FILE( cPath )
ENDFUNCTION