Hi Gavin,
The notepad and some other editors don't keep file open. They load it into memory and work with that copy. In case like that file isn't technicaly open.
>Hi All,
>
> I've come across a strange one when using VFP6.0 SP5 to copy data to a comma delimited file. I have a generic print screen in my application that allows any report in the application to be output to printer, preview, excel, pdf or delimited file. The following code performs the delimited copy and checks a flag to see if there was an error.
>
>
>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"
>ENDIF
>
>
>I 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.
>
>But if I try the following code:
>
>
>USE mytable
>COPY TO mytextfile.txt DELIMITED
>MODI COMM mytextfile.txt NOWAIT
>COPY TO mytextfile.txt DELIMITED
>
>
>I 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?
>
>Thanks,
>Gavin.
--sb--