Hello all,
how do I open an dbf file if the according memofile (.ftp) is missing (without prompting an error)?
Thanks in advance for your help
// The example implements a user-defined function that reads the
// entire contents of a file into a memory variable using
// low-level file functions:
#include "FileIO.ch"
PROCEDURE Main
LOCAL cFile := "test.dbf" //"MyFile.txt"
LOCAL cStream
IF .NOT. ReadStream( cFile, @cStream )
IF FError() <> 0
? "Error reading file:", FError()
ELSE
? "File is empty"
ENDIF
ELSE
? "Successfully read", Len(cStream), "bytes"
ENDIF
RETURN
FUNCTION ReadStream( cFile, cStream )
LOCAL nFileHandle := FOpen( cFile )
LOCAL nFileSize
IF FError() <> 0
RETURN .F.
ENDIF
nFileSize := FSeek( nFileHandle, 0, FS_END )
cStream := Space( nFileSize )
FSeek( nFileHandle, 0, FS_SET )
FRead( nFileHandle, @cStream, nFileSize )
FClose( nFileHandle )
RETURN ( FError() == 0 .AND. .NOT. Empty( cStream ) )
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: nageswaragunupudi and 45 guests