* Purpose Remove Ctrl+Z (EOF) character from the end of the text file * usualy created by COPY SDF TO comment * Param's The name of the file * Return .T. if operation was sucessfull PARAMETER pcFileName IF NOT FILE(pcFileName) WAIT' ERROR: FILE '+pcFileName+' DOES NOT EXIST' WINDOW RETURN .F. ENDIF PRIVATE nHandle, nFileSize, cData, cNewSize, nIOError, lRet * Open the file nHandle = FOPEN(pcFileName,2) * Get it size nNewSize = FSEEK(nHandle,-1,2) *nFileSize = FSEEK(nHandle,0,2) * Read the last byte of it cData = FREAD(nHandle,1) lRet = .T. * Check if it's Ctrl+Z IF ASC(cData) = 26 IF FCHSIZE(nHandle, nNewSize) < 0 nIOError = FERROR() WAIT 'ERROR WRITING TO FILE: '+ALLTRIM(STR(FERROR())) WINDOW lRet = .F. ENDIF ENDIF =FCLOSE(nHandle) RETURN lRetIn VFP 6 it can be done in a few lines of code
lcData = Filetostr("Myfile.csv") IF ASC(RIGHT(lcData,1)) = 26 && make sure that its CTRL+Z = Strtofile(LEFT(lcData, LEN(lcData)-1), "Myfile.csv") ENDIF>I am trying to create a csv file from a foxprox table to be uploaded by another