USE mytable cError = ON("ERROR") lOkToCreate = .T. ON ERROR lOkToCreate = .F. COPY TO myfile.txt DELIMITED WITH ~ ON ERROR &cError IF lOkToCreate = .F. * ----- Insert appropriate error message WAIT WINDOW "File in use" ENDIFI then open the file in windows notepad and try the previous code again. To my surprise I don't get a message saying that the text file is in use.
USE mytable COPY TO mytextfile.txt DELIMITED MODI COMM mytextfile.txt NOWAIT COPY TO mytextfile.txt DELIMITEDI get a 'File is in use' error. It seems that certain text editors don't lock the file. Does anyone know of a fool proof way to check that a file isn't in use before trying to create it?